views:

802

answers:

1

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. I've set android:clearTaskOnLaunch="true" on LogonAct.

When I first start the app I go through this sequence of screens,

Home -> LogonAct -> MainAct -> Home

I then follow this sequence,

LogonAct -> Back -> MainAct

Why is it bringing me back to MainAct? Shouldn't that activity haven been closed since LogonAct has android:clearTaskOnLaunch="true". I expected to be brought back to Home when I hit the Back button from LogonAct.

Relevant snippets from AndroidManifest.xml,

   <activity android:name=".LogonAct"
             android:clearTaskOnLaunch="true">
       <intent-filter>
           <action android:name="android.intent.action.MAIN"/>
           <category android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
   </activity>

   <activity android:name=".MainAct">
       <meta-data android:name="android.app.default_searchable"
                  android:value=".SearchResults" />
   </activity>

I'm using 1.5.

Any help appreciated.

+1  A: 
Christopher
Thanks for your help Christopher.I have a few more activities that can come after MainAct so if I use android:noHistory on MainAct these other activities fall back to the logon screen when I select Back.I fully agree that logging on each time you come to the app isn't ideal. It's a password manager app so I didn't want to leave it accessible for too long. What I'm going to try and do is have a timer that works in a similar fashion to sudo, i.e. request the password if it's been more than x seconds since it was last entered.
Adrian
Ah. In that case, you could add a quick method call in `onResume()` of each `Activity` you have that checks whether a certain time period has elapsed. If so, then call `finish()` and fire an `Intent` to send them back to the `LogonAct`.
Christopher