I want to lock my application when it goes in background and when it resumes I want to display my own lock screen. The lock screen is an Activity of my application.
Aft
You can achieve that if you have a global Activity "MyActivity" and all the activities extend from it.
Then you override onPause and onStop methods on "MyActivity"
@Override
public void onPause()
{
super.onPause();
setLockStatus(false);
}
@Override
public void onStop()
{
super.onStop();
setLockStatus(true);
}
and:
@Override
public void onResume()
{
super.onResume();
checkLockScreen();
}
EDIT: Obviously you need to create the methods setLockStatus and checkLockScreen and do whatever you want (like save the status on sharedPreferences).