which event calling in the previous activity when the onbackpressed is called in the current activity?

StackOverflow https://stackoverflow.com/questions/20424787

  •  29-08-2022
  •  | 
  •  

Question

when I click the button to close the application it back to a previous screen that the activity is still open, I need to close it. so I want to handle the event return to onbackpressed

Was it helpful?

Solution

Try this:

When you will start a new Activity start like this:

// Launch Dashboard Screen
Intent dashboard = new Intent(getApplicationContext(),DashboardActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Login Screen
finish();

OTHER TIPS

Override the onBackPressed method and close both your Activity

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top