user1767260 user1767260 - 5 months ago 14
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

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{

    @Override
    public void onResume()
    {
        super.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:

@Override
public void onUserInteraction(){
    // reset your timer...
    super.onUserInteraction();
}    
Comments