Android - How To Override the “Back” button so it doesn't Finish() my Activity?

后端 未结 10 1252
粉色の甜心
粉色の甜心 2020-11-22 08:07

I currently have an Activity that when it gets displayed a Notification will also get displayed in the Notification bar.

This is so that when the User presses home a

10条回答
  •  野性不改
    2020-11-22 08:47

    @Override
    public void onBackPressed() {
    // Put your code here.
    }
    
    //I had to go back to the dashboard. Hence,
    
    @Override
    public void onBackPressed() {
        Intent intent = new Intent(this,Dashboard.class);
        startActivity(intent);
    }
    Just write this above or below the onCreate Method(within the class)
    

提交回复
热议问题