-1

I am new to Android. I am doing simple app with login/logout. My launcher activity is HomePageActivity. At HomePageActivity user authorization is checked and if user is not logged in he is sent to LoginActivity. The problem is that when user clicks physical "back" button he is sent to HomePageActivity.

How can i prevent this?

yerassyl
  • 2,958
  • 6
  • 42
  • 68
  • http://stackoverflow.com/questions/4779954/disable-back-button-in-android guy with your reputation should know how to use stack – maciej Aug 31 '15 at 11:47

2 Answers2

2

Try to finish() the activity before sending to login activity, and then the back button won't be able to navigate to the HomePageActivity activity.

For example:

finish();
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent); 
Avihoo Mamka
  • 4,656
  • 3
  • 31
  • 44
0

Handle onBackPressed(); for your activity

@Override
    public void onBackPressed() {
        super.onBackPressed();
        // Your code
    }
Amarjit
  • 4,327
  • 2
  • 34
  • 51