I am developing an Android application and I want it to pause music when you press the home button (onPause). This works well, but then when I try to start the game again, onResume, onRestart, onStart, onRestoreInstanceState and onCreate are never called, and this tells me that the application is not responding. LogCat has no exceptions. Therefore, I have no idea what is happening. Does anyone have any suggestions as to why this might be so?
-EDIT- I get this error in LogCat when the application pauses:
04-16 20: 09: 32.659: ERROR / ActivityManager (66): Reason: broadcast intent {act = android.intent.action.CLOSE_SYSTEM_DIALOGS cmp = com.android.settings / .widget.SettingsAppWidgetProvider (has additional functions)}
my onPause () code is:
public void onPause() {
super.onPause();
panel.mediaPlayer.pause();
panel.thread.running=false;
}
The main thread of the application:
public void run() {
running = true;
while(running) {
Canvas c = null;
update();
try {
c = surfaceHolder.lockCanvas(null);
synchronized(surfaceHolder) {
doDraw(c);
try {
Thread.sleep(gameSpeed);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} finally {
if (c != null) {
surfaceHolder.unlockCanvasAndPost(c);
}
}
}
mediaPlayer:
mediaPlayer = new MediaPlayer();
sublime = context.getResources().openRawResourceFd(R.raw.sublime);
try {
mediaPlayer.setLooping(true);
mediaPlayer.setDataSource(sublime.getFileDescriptor(), sublime.getStartOffset(), sublime.getLength());
mediaPlayer.prepare();
} catch (IllegalArgumentException e1) {
} catch (IllegalStateException e1) {
} catch (IOException e1) {
}
mediaPlayer.start();
source
share