Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require login every time user returns to Android application

I am working on an Android app that deals with sensitive user information. One of the requirements is that the user is required to log back into the application whenever they leave it and come back. This is easily dealt with for the case when the user presses the Home button and then relaunches the app (android:clearTaskOnLaunch attribute on the Activity in AndroidManifest.xml). However, we need to do the same thing when the user long presses the Home button, switches to another application, then comes back.

I have researched this every way that I can think of and have not found a workable solution. Is this even possible with Android?

When answering, please keep in mind that this is a business requirement which I have no control over.

like image 466
Brent Edwards Avatar asked Nov 26 '22 15:11

Brent Edwards


1 Answers

Well, I had the same problem yesterday. This is what I did and it works fine:

  1. Added android:launchMode="singleTask" to the main activity in the AndroidManifest.xml
  2. Called my boss and say: ey, this is going to take a long while... hold on!
  3. Went and drank beer all night.

Just to clarify, my main activity only has a button that says login and launches the login page.

like image 51
Cristian Avatar answered Dec 05 '22 05:12

Cristian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!