문제

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

도움이 되었습니까?

해결책

You can override onBackPressed in your activity

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

다른 팁

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;
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top