android:选择哪个活动应该是第一个活动
我有一个登录屏幕,一旦用户登录,我已成功从历史记录中删除该登录屏幕。
但即使现在,如果我按后退按钮并再次打开应用程序,它也会显示登录屏幕。如何确保用户登录后,应用程序应该只显示主屏幕?
这是我用来禁用历史记录的代码
android:noHistory="true"
我想我应该在应用程序类的 onCreate 中添加一个覆盖?
@Override
public void onCreate(){
super.onCreate();
// anything else that we need to do, when app is run.
}
I have a login screen, that i have successfully deleted from history once the user logs in.
But even now if i press the back buttom, and open the application again, it shows the login screen. How do i ensure that once the user logs in, then the application should only show the home screen?
here is the code that i am using to disable history
android:noHistory="true"
i guess i should add an override in the onCreate of my application class?
@Override
public void onCreate(){
super.onCreate();
// anything else that we need to do, when app is run.
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单的解决方案是在登录/主屏幕活动之前添加一个新活动。在此活动中,您检查是否需要登录并触发所需的活动:
The easy solution is to add a new activity before the Login/HomeScreen activities. In this activity you check if Login is needed and fire the desired Activity:
您可以向登录活动添加方法
登录活动将被销毁。
You can add method to login activity
Login activity will be destroyed.