正确跳过登录活动是否已经登录 [英] Properly skip login activity if already logged in

查看:137
本文介绍了正确跳过登录活动是否已经登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的启动器图标现在开始登录活动。我保存登录的共享preferences状态。有没有办法为正确跳过登录活动,直接进入的主要活动,而不任何 UI毛刺。涉及完成()的onCreate()所有现有的解决方案事业登录活动标题要简短可见或其他一些简单的空白屏幕UI毛刺。

My launcher icon currently starts the login activity. I've stored the logged in status in SharedPreferences. Is there any way to properly skip the login activity and go straight to the main activity without any UI glitches. All existing solutions involving finish() in onCreate() cause the login activity title to be briefly visible or some other brief blank screen UI glitch.

推荐答案

有一个发射acitivy没有用户界面,决定打开MainActivity或LoginActivity。你可以声明没有UI搭配:

Have a launcher acitivy with no UI that decides to open the MainActivity or the LoginActivity. You can declare no UI with:

android:theme="@android:style/Theme.NoDisplay"

另外两个可能的解决方案:

Two other possible solutions:

只要做到这一点周围的其他方法:使你的mainActivity你的发射器,并使其检查用户是否登录然后重定向到l​​oginActivity的时候,这是不是这样

Just do it the other way around: make your mainActivity your launcher and make it check whether the user is logged in. Then redirect to the loginActivity when this is not the case.

另一种方法是用片段工作。有可以加载这两个mainFragment和loginFragment基地的活动。供参考:<一href="https://developer.android.com/training/basics/fragments/index.html">https://developer.android.com/training/basics/fragments/index.html

Another way is to work with fragments. Have a base activity that can load both the mainFragment and the loginFragment. For reference: https://developer.android.com/training/basics/fragments/index.html

这篇关于正确跳过登录活动是否已经登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆