I have an application with 2 activities, LogonAct and MainAct. LogonAct is a logon activity which I want to force the user to go through each time they return to the application
The docs for android:clearTaskOnLaunch
mention that this attribute applies "whenever [the Activity] is re-launched from the home screen".
However, in your case you're pressing the Home button to return to the Home screen, rather than pressing the Back button. This means your application isn't actually relaunched because the MainAct
was not "finished". That only happens when you press Back (or if Android kills the task to save resources etc.).
As you only have two activities in your application, you could set the android:noHistory attribute on MainAct
, thus ensuring that users can never return to it and must pass through the LogonAct
.
As an aside, it seems a bit annoying to force users to re-login every time they navigate away from the app (for example when they receive a phone call).
You could retain a session token with timeout in your app's persistent storage, or hold a network connection open using a service if that's how your app works — but of course that's up to you and your requirements. :)