阻止 Android 中的应用程序
对于我的应用程序,我实现了一个系统来检测当前版本是否是需要更新的旧版本。顺便说一句,检测按预期工作。
我的问题是发生这种情况时如何阻止应用程序的使用。现在我正在启动一项活动来通知用户并授予市场链接。我的问题是,如果用户按后退按钮返回到最后一个活动,并且
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
} else {
return super.onKeyDown(keyCode, event);
}
}
当用户按后退按钮并且不返回到其他活动时,我不知道如何更改 For 退出应用程序。 谢谢!
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) {
} 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以对其他活动调用
finish()
,但我不确定您如何获得对它们的引用。据我所知,Android 系统不允许程序员结束任务(其中在其后堆栈中包含多个活动),而这正是您想要做的。
您可以尝试使用片段而不是活动,这将允许您在它们之间传递信息和事件。
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.
在启动新活动之前,请确保在主活动(主应用程序的过时版本)上调用 finish() 以从后台堆栈中删除。
Before laucnhing the new activity, make sure to call finish() on main activity (outdated version of main app) to remove from back stack.