Question

I have an application running on Samsung Galaxy Tab 8.9 with Android 3.1.

I have to disable Back button. I know that

<category android:name="android.intent.category.HOME" />

disables the Home button. But I don't want to disable the Home button. I want to disable only the BackButton and not the HomeButton.

Thanks everyone..

Was it helpful?

Solution

You can override onBackPressed in your activity

@Override
public void onBackPressed() {
    //do nothing
}

OTHER TIPS

Simply override onBackPressed() like this:

@override
public void onBackPressed(){}

Use this in your activity to override the BackButton :

@Override
public void onBackPressed() {
    // whatever you want to do when the BackButton is pressed.
}
@Override 
public boolean onKeyDown(int iKeyCode, KeyEvent event)
{

    if(iKeyCode == KeyEvent.KEYCODE_BACK || iKeyCode == KeyEvent.KEYCODE_HOME) 
    {
        return true;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top