how to disable the default back button in android [duplicate]
Possible Duplicate:
Disable back button in android
in my app to from one activity to other just like A->B->C or C->A i have placed buttons because the operations of the app are like that. So there is no need for the 开发者_JAVA百科default back button of android. If the user wrongly clicks there should not be any operation done. For this how to disable the back button.
If you don't want to return to a specific Activity, another approach would be to call finish() after startActivity()
from Activity B.
Code snippet:
Intent i = new Intent(this, C.class);
startActivity(i);
finish();
I don't think that you should disable the back button for users. They would probably get angry/upset. I would at least be that.
It's better to either start the activity with FLAG_ACTIVITY_NO_HISTORY or FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.
Intent intent = new Intent(this, YourActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
精彩评论