fix NPE in AndroidHarness when quitting (thanks iwgEric)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9241 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 511a11fc7c
commit 1a771236cf
  1. 34
      engine/src/android/com/jme3/app/AndroidHarness.java

@ -230,12 +230,14 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
view.onResume(); view.onResume();
} }
//resume the audio if (app != null) {
AudioRenderer result = app.getAudioRenderer(); //resume the audio
if (result != null) { AudioRenderer result = app.getAudioRenderer();
if (result instanceof AndroidAudioRenderer) { if (result != null) {
AndroidAudioRenderer renderer = (AndroidAudioRenderer) result; if (result instanceof AndroidAudioRenderer) {
renderer.resumeAll(); AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
renderer.resumeAll();
}
} }
} }
@ -250,18 +252,20 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
view.onPause(); view.onPause();
} }
//pause the audio if (app != null) {
AudioRenderer result = app.getAudioRenderer(); //pause the audio
if (result != null) { AudioRenderer result = app.getAudioRenderer();
logger.log(Level.INFO, "pause: {0}", result.getClass().getSimpleName()); if (result != null) {
if (result instanceof AndroidAudioRenderer) { logger.log(Level.INFO, "pause: {0}", result.getClass().getSimpleName());
AndroidAudioRenderer renderer = (AndroidAudioRenderer) result; if (result instanceof AndroidAudioRenderer) {
renderer.pauseAll(); AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
renderer.pauseAll();
}
} }
} }
isGLThreadPaused = true; isGLThreadPaused = true;
logger.info("onPause"); logger.info("onPause");
} }
@Override @Override
@ -448,7 +452,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
public void destroy() { public void destroy() {
if (app != null) { if (app != null) {
app.destroy(); app.destroy();
} }
if (finishOnAppStop) { if (finishOnAppStop) {
finish(); finish();
} }

Loading…
Cancel
Save