I'm developing an app for Android, and I want it to pause the music when you press the home button (onPause). That works fine, but then when I try to start up the game again, onResume, onRestart, onStart, onRestoreInstanceState and onCreate are never called and it tells me that the application is not responding. There are no Exceptions shown in the LogCat... So I have no idea what is happening. Does anyone have any suggestions as to why this might be the case?
-EDIT- I do get this error in the LogCat when the application pauses:
04-16 20:09:32.659: ERROR/ActivityManager(66): Reason: Broadcast of Intent { act=android.intent.action.CLOSE_SYSTEM_DIALOGS cmp=com.android.settings/.widget.SettingsAppWidgetProvider (has extras) }
my onPause() code:
public void onPause() {
super.onPause();
panel.mediaPlayer.pause();
panel.thread.running=false;
}
Main application thread:
public void run() {
running = true;
while(running) {
//new Canvas.
Canvas c = null;
//Update information
update();
//Draw everything to screen
try {
//Gets the canvas from the surfaceHolder.
c = surfaceHolder.lockCanvas(null);
synchronized(surfaceHolder) {
//draw to the canvas
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();