I am creating a home screen lock application. i want to disable the home button so that the user cant go further without unlocking the screen.
As we know as long as we are not the home screen we cant really disable the home button. so i started my activity again in my onPause()
method. so that when user press home button the application goes to background and onPause()
is fired and i start the activity again.
@Override
protected void onPause() {
super.onPause();
startActivity(new Intent(getApplicationContext(), LockScreen.class).setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION));
finish();
}
but the problem once the home button is pressed the app goes to background and it takes like 2 seconds to again start the activity and come to foreground.
Is there any faster solution for this ? how can i start the activity as soon as the home button is pressed ?
Update
Do not tell e we have to be the home screen to able to disable the home button . if this is the case then there must be a walk around because screen lock apps do it.
My question has been marked as duplicate . but please read the answer given . it does not answer my question. i want to override the home button without being the home screen . and if you say its not possible then please see any screen lock app in play store. so please suggest any other solution. you ca search the whole SO and please delete this question if you can still find a working answer to this question. and if not please dont suppress the question.