android - How to clear stack back to root activity when user leaves application? -
I have an application with 2 activities, logonact, and menact. LogonAct is a logon activity that I want to force the user to return to the application every time. I have set Android: LogonAct on Android: ClearTaxNowLow = "True" .
When I start the app for the first time, I go through this sequence screen
Home -> LogonAct - & gt; Menact - & gt; Home
Then I follow this sequence,
logonact -> Back - & gt; Men Act
Why is it bringing me back to the menu? That activity should not be discontinued since Android: ClearTaskOnLock = "True" next to LogonAct. I'm hoping to get back to the button from LogonAct.
Snippet related to AndroidManifest.xml,
& amp; Activity Android: Name = "LogonAct" Android: clearTaskOnLaunch = "true" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.MAIN" /> & Lt; Category android: name = "android.intent.category.LAUNCHER" /> & Lt; / Intent-Filter & gt; & Lt; / Activity & gt; & Lt; Activity Android: name = ". MainAct" & gt; & Lt; Meta-Data Android: name = "android.app.default_searchable" Android: value = ". SearchResults" /> & Lt; / Activity & gt;
Docs for android: ExplicitTextOneLine
mentions that this feature "whenever [the activity ] Is restarted from the home screen. "However, in your case, you will be given a < back button to return to the home screen instead of < Kbd> Home button means that your application is not actually resumed because
main act
"end" It only happens when you press back (or if Android drills the work to save resources.).As you have only two activities in your application You can set the attribute on the
Main Act
, thus ensuring that users never return it and will have to go through thelogon act
. < / P>On one side, it seems a bit annoying to users For navigating away from each other, force them to enter again (for example, when they receive a phone call).
You can maintain a session token with timeout in your app's continuous storage, or if your app works by opening a network connection & mdash; But of course, you and according to your needs :)
Comments
Post a Comment