开发者

Block the application in Android

For my application I have implemented a system that detects if the current version is an old version that requires an update. By the way the detection work as intended.

My problem is how to block the application use when that happens. By now I'm launching an activity for inform the user and grant a link to the Market. My problem is that if the user press the back button returns to the last Activity and I dont know how to change the

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {开发者_C百科

    } else {
        return super.onKeyDown(keyCode, event);
    }
}

For exit the application when the user press backs and don't go back to the other activities. Thanks!


You can call finish() on the other activities, but I'm not sure how you'd get a reference to them.

To my knowledge the Android system does not let the programmer end tasks (which contain multiple activities in their back stacks), which is what you're trying to do.

You could try using Fragments instead of Activities, which will let you communicate information and events between them.


Before laucnhing the new activity, make sure to call finish() on main activity (outdated version of main app) to remove from back stack.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜