开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜