Hello all,

I want to protect my application with password. My imagination how it
should work:

1. When a user launches the application for the first time from the
Home screen, password is requested.
2. When the user launches the application for the 2nd (3rd and so on)
time the Home screen, password is requested.
3. When the user exits application pressing Home button and then
returns back to the application after choosing application from the
applications list (after long press on the Home button), password is
requested;
4. When foreground activity is interrupted by some other activity
(onPause is called, but not onStop since activity is still visible),
password is not requested.

I found an approach which handles 1, 2 and 4 (I use custom Application
class which has its own activity counter), but I don't have a clue how
to implement #3. I need  to detect a fact that the application goes to
background (any activity is visible to the user, thus we can
invalidate previous authentication).

When on Stop is called, I don't know why it is called, but I need to
distinguish cases when:
- application is returned to the previous or next application activity
due to the user input (some action in UI, or pressing Back button);
- application goes to the background due to the another application or
pressing Home button by the user.

Any elegant way to handle this (I know can intercept all finish()/
startActivity()/startSubactivity() calls, set some flag and analyze it
in the onStop(), but it looks too dumb, so I'm looking for better
solution)?

Thank you in advance.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to