Avoid Killing of Activity in Android
I want create an Activity in Android 开发者_开发问答which never kill (on long press of Back Button) until specific condition fulfill.
How I can achieve this ?
Thanks.
You could override the back button and only let the activity finish if the 'conditions have been met'.
@Override
public void onBackPressed() {
if(conditionIsMet) {
//The condition was met, close the activity
finish;
} else {
//Cancel the button press
return;
}
}
I hope this is the answer you were looking for, but your question wasn't too clear.
精彩评论