Is this a way to disable the BACK button on a mobile device? because as long as I transfer it to my mobile, the BACK button is activated so that it can return to the previous page. Please help me disable the BACK button while my application is running.
Override onBackPressed()your activity
onBackPressed()
@SuppressLint("MissingSuperCall") @Override public void onBackPressed() { // super.onBackPressed(); // Comment this super call to avoid calling finish() or fragmentmanager backstack pop operation. }
You can suppress the lint error by adding @SuppressLint("MissingSuperCall")as directed by Matthew Reed.
@SuppressLint("MissingSuperCall")
Android , Activities (, cocos2d-x):
Activities
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { return (keyCode == KeyEvent.KEYCODE_BACK ? true : super.onKeyDown(keyCode, event)); }
It is very simple. Put this code in every action of your Android code if you want to disable the back button for full use
@Override public void onBackPressed() { //thats it }
and you are done