-10

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?

Suraj Makhija
  • 1,376
  • 8
  • 16

3 Answers3

2

simply write these lines

 @Override
public void onBackPressed() {

}
AMAN SINGH
  • 3,491
  • 6
  • 28
  • 44
2

You can simply use this if you want to disable completely back button:

 @Override
    public void onBackPressed() {
        moveTaskToBack(false);
    }
Johny
  • 625
  • 2
  • 6
  • 26
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();
    }