I want to disable back button in my application. And if not possible, then I want to open MainActivity when click on it. Is there any solution? If yes help me?
Asked
Active
Viewed 5,953 times
3 Answers
2
simply write these lines
@Override
public void onBackPressed() {
}
AMAN SINGH
- 3,321
- 5
- 24
- 44
-
1this is not working – Dinesh Sheoran Apr 03 '17 at 13:09
-
show me your code. how's this possible. is it Activity class? – AMAN SINGH Apr 03 '17 at 13:11
2
You can simply use this if you want to disable completely back button:
@Override
public void onBackPressed() {
moveTaskToBack(false);
}
Johny
- 595
- 1
- 6
- 25
0
you can use this code for onback button click to intent another activity.
@Override
public void onBackPressed() {
Intent intent=new Intent(Caly_act.this,MainActivity_tab.class);
startActivity(intent);
finish();
}
Hasmukh Kachhatiya
- 470
- 4
- 13