Consider following situation:
I have an application, which contains some critical information (e.g. banking app). The application itself has multiple screens.
I would like to have the following behavior: Every time after application becomes inactive for any reason (e.g.: user pressed "home" button, user switched to other app using list of recent tasks, user shut down display with power button, input call happened etc...)... so every time after that I want, that when user comes back to the app, the password is requested.
The first solution, which comes to mind is to request password every time in onResume()
. But this of course does not work, because this method is also called, when internal transition from one activity to another within the application happens (and of course, at this point the password should not be requested).
So to solve this I would need to know, if onResume()
was triggered from "internal transition" or from outside the application.
I would be very grateful, if someone could suggest, how to do it.
If there is another solution to the problem, I would also be happy to know it.
Thank you.
question from:
https://stackoverflow.com/questions/65833428/android-how-to-find-out-if-activity-was-started-or-resumed-comes-to-foregroun 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…