简体   繁体   English

android - 从我的应用程序中的上次访问页面恢复

[英]android - resuming from last visited page in my app

I have login page (activity) which is my first activity (landing page) of the app. 我有登录页面(活动),这是我的应用程序的第一个活动(登录页面)。 Only after user gives correct username and password, the app allow you go to other pages to work with. 只有在用户提供正确的用户名和密码后,该应用才允许您转到其他页面进行操作。

Now my question is, now the user is at the fourth page and he is working on it, And he minimize the app and use other app like messaging etc.. so when he come back to click my app icon again, my app starts from the first landing page, which is the login page, how can I make my app to resume from the fourth page? 现在我的问题是,现在用户在第四页,他正在努力,并且他最小化应用程序并使用其他应用程序,如消息等。所以当他回来再次点击我的应用程序图标时,我的应用程序从第一个登录页面,即登录页面,如何让我的应用程序从第四页恢复?

Android 4.4.4, Kit Kat, Samsung Android 4.4.4,Kit Kat,三星

Regards, Nay TK 此致,Nay TK

Add this in android manifest of loginActivity , 在loginActivity的android清单中添加它

android:launchMode="singleTask" 

more on android:launchMode 更多关于android:launchMode

An instruction on how the activity should be launched. 关于如何启动活动的说明。 There are four modes that work in conjunction with activity flags (FLAG_ACTIVITY_* constants) in Intent objects to determine what should happen when the activity is called upon to handle an intent. 有四种模式与Intent对象中的活动标志(FLAG_ACTIVITY_ *常量)结合使用,以确定在调用活动处理意图时应该发生什么。 They are: 他们是:

"standard" “标准”

"singleTop" “singleTop”

"singleTask" “singleTask”

"singleInstance" “singleInstance”

The system creates the activity at the root of a new task and routes the intent to it. 系统在新任务的根目录下创建活动,并将意图路由到该任务。 However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one. 但是,如果活动的实例已存在,系统会通过调用其onNewIntent()方法将意图路由到现有实例,而不是创建新实例。

go through official link for more detail 通过官方链接了解更多详情

You can make your fourth activity as your launch activity. 您可以将第四个活动作为启动活动。 In the Resume of your Activity, you check if the user is logged in. If not, you start your Login activity. 在“恢复活动”中,检查用户是否已登录。如果没有,则启动“登录”活动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM