I searched a lot to block Home key but no success and finally I got it and here it is for you guys.
@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
Note: You should never block the Home key. Please see this post before doing so.
@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
Note: You should never block the Home key. Please see this post before doing so.
It worked fine, but the activity is showing the notification bar which i don't want to.
ReplyDeleteI have these 2 lines placed on (onCreate) method:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
when I add your method; the notification bar appears.
Kindly advice
Yes, it is the issue with this code. I have tried a lot but no luck. If you find something then do let me know.
ReplyDelete@Vineet - Although I appreciate that you have taken time to share this but this must be considered a criminal offense in the android environment! Any app that enforces such constraints could be considered to be malware.
ReplyDelete@ABHIJIT I agree with you and for that reason I have left a note with a post why Home key should not be intercepted.
ReplyDelete