Reputation: 3858
I would like to show a specific activity every time the app resumes. This activity contains a login form to authenticate the user. For instance, when the user press the home button and then the icon of the app, this activity should appear in order to be sure of who is using the app.
How can I do that, please?
Upvotes: 1
Views: 587
Reputation: 3858
I've found another solution.
When an activity goes on pause, get the timestamp. When it become active again get another timestamp. If the difference between the timestamps is pretty long, start the login activity otherwise, continue with the resuming of the current activity.
Upvotes: 0
Reputation: 18151
Make you Login activity your launcher activity and add android:clearTaskOnLaunch in your manifest
<activity
android:name=".LoginActivity"
android:label="@string/app_name"
android:clearTaskOnLaunch="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 4