Search code examples
androidback-buttonandroid-homebutton

what's the name of 3rd number button and how to control 2 and 3 button?


I want to control this 3 buttons back,home,3rd button I know using onbackpressed the back button is control but how can I control or disable the home button and 3rd button here I put it image you can check this. I have tried on back pressed and it works.

Back Button

@Override
public void onBackPressed() 
{
    // some work
}

enter image description here


Solution

  • 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.

    There are few things that you can try:

    You can set your activity single top, and start it over with clear to top flag when onPause() method is called, this will block the home button and opening other activities.

    Listen to BOOT_COMPLETED broadcast to start your activity - this will protect you from users who will take the battery out of the device in order to reboot it.

    Add Alarmmanager that will test every second if your app is alive and if it is not, then start it - This will protect you from userers that some how managed to close your app(may be with external tools).

    Do this and no one be able to exit your app.