override Home key in android ICS

后端 未结 1 1228
野性不改
野性不改 2020-12-20 00:21

I need to override HOME key in my application. I\'ve used code from this post but it\'s not working on android 4.X. Do you know other workarounds to achieve this task? I\'ve

相关标签:
1条回答
  • 2020-12-20 01:01

    Post ICS i.e. Android 4+, the overriding of the HomeButton has been removed for security reasons, to enable the user exit in case the application turns out to be a malware.

    Plus, it is not a really good practice to not let the user navigate away from the application. But, if your application requires so, what you can do is declare the activity as a Launcher , so that when the HomeButton is pressed it will simply restart your application and remain there itself (the users would notice nothing but a slight flicker in the screen).

    EDIT #1 : Here is another workaround, more suited to your needs.

    EDIT #2 : Just came across this. Haven't tested it. But looks kinda promising. Not sure if it would work, but you could give it a try.

    0 讨论(0)
提交回复
热议问题