I have onPause in activity and works great. This is code
@Override
protected void onPause() {
super.onPause();
Intent intent;
intent = new Intent(Games.this, PauseScreen.class);
startActivity(intent);
}
But I have a problem. When I push the back button onPause is calling and start new activity. I want to onPause works always except when I click back button on my phone. How I can do this? I think that may be if(backbutton was click){onPause is not working}else{onPause working} but I don’t know how implement this solution. Or maybe you have better idea?
@user1302569
Here are step you can follow to achieve your desire behavior in Application..
STEP 1: Overide this back Key method in your Activty.
STEP 2: Take One boolean variable like below in your Activity Class.
STEP 3: in your OnPause Method do some thing like Below
STEP 4: in Your Activity’s OnResume Make sure this also.
}
Regarding Back Key Event in Android ,in Developer site you can refer this http://android-developers.blogspot.in/2009/12/back-and-other-hard-keys-three-stories.html