user1767260 user1767260 - 2 years ago 78
Android Question

Android - Show lock screen when application resumes in android

I need to show a lock screen when application comes from background and also after a time duration. I have searched a lot. But not found any useful solution. Please help me. Thanks in advance.

Answer Source

From your added information in the comments, I'd suggest you have one base activity that implements your desired behavior and have your other activities inherit from that one.

It could look somewhat like this:

public class BaseActivity extends Activity{

    public void onResume()
        // check if you want to display your login

If you want to show your login after a set amount of time of inactivity, you could implement that in BaseActivity, too:

public void onUserInteraction(){
    // reset your timer...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download