Денис Климков Денис Климков - 4 months ago 21
Android Question

How prevent the transition to activity

I have two activities. One activity is the authorization activity and the other navigation drawer with fragments. When I walk the way of registration and get on the navigation, I should not get to the login activity using the system back button.

How can I block this transition, if my system buttons busy:

@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}

Answer

Not sure if I understood correctly, but if you don't want your application coming back to login activity you should finish it after starting your navigation activity.

void onAuthorized() {
    Intent intent = new Intent(this, NavigationActivity.class);
    startActivity(intent);
    finish();
}