user632905
user632905

Reputation: 1000

Disable Home Key

i am trying to create a lock screen and for that i need to disable the home button..

i found the following code, its recommended by many and I tried it:

@Override
public void onAttachedToWindow()
{  
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
    super.onAttachedToWindow();  
}

@Override

public boolean onKeyDown(int keyCode, KeyEvent event) {
    return false;
}

Now i know what its doing, I tried it on HTC Explorer, Sony Ericsson Experia Neo V, and Samsung Galaxy S2..

The code works in HTC and Sony but it seems to have no effect on Samsung Galaxy s2.. Please note that Samsung is rooted while others not...is rooted device the problem??

Any Suggestions pls?

Upvotes: 0

Views: 2327

Answers (2)

Gabriel Ittner
Gabriel Ittner

Reputation: 1162

The only way to overwrite the home button in android is to act as a home replacement, so your app is opened when home is pressed. The user has to set your app as default app and when the screen is unlocked you open the default launcher.

The lockscreen in android isn't meant to be replaced.

Upvotes: 1

dldnh
dldnh

Reputation: 8961

I believe the problem is that the Home key really isn't meant to be disabled.

Upvotes: 3

Related Questions