I'm a begginer android programmer, and I seem to have a problem: I open new activitys, with
Intent newGameIntent = new Intent(actionName);
startActivity(newGameIntent);
and everythings works fine, the activity opens. but when i call finish() it doesnt goes to the previus activity, it just closes the app(no errors or other log messeges)
does anyone have an idea why is it happening? Thanks for your time!
by request, here is more of the code(of the stuff that i might have totally screwd up): first activity:
@Override
protected void onStop() {
super.onStop();
SplashScreen.sounds.releasSounds();
finish();
}
@Override
protected void onPause() {
super.onPause();
pauseActivity();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
gameLoop.resumeThread();
SplashScreen.sounds.resumeSounds();
}
private void pauseActivity() {
gameLoop.pauseThread();
SplashScreen.sounds.pauseBck();
}
and the first activity calling the seconds activity
Intent newGameIntent = new Intent("com.YuvalApps.menus.NEWGAMEMENU");
startActivity(newGameIntent);
and for the seconds activity
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
When one activity was in background, The android system will invoke "onStop" method, But you invoke the method "finish" in method "onStop", So if you jump to another activity, the previous activity will destroyed by "onStop". You should remove "finish" in "onStop" method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With