I have an activity.. when it is calls onPause() it starts a new activity.. Problem is when I lock screen of my phone..It calls the onPause which cause it to go back to the main activity but I want to stay in that activity.. Is there a way to fix this ?
This is the code snippet if it helps..
@Override
protected void onPause() {
super.onPause();
call_next_activity(call_next_act);
}
private void call_next_activity(Boolean call_next) {
if (!call_next)
return;
Intent select_one;
if (program_id) {
select_one = new Intent("c.theworld.com.nikhil.MENU");
} else {
select_one = new Intent("c.theworld.com.nikhil.CHAPTER");
Chapter.call_menu = true;
}
startActivity(select_one);
}
You really, really, really shouldn’t put something like that in onPause().
onPause() is a lifecycle indicating the activity is stopping for some reason, the user presses home, back, gets a phone call. Many events outside your control can cause onPuase() to be called.
You should most definitely not start anything in the onPause() method, Re-factor your app to work differently is what you need to do.