Search code examples
androidandroid-activity

Android skip activity on back button press


I have a login screen in which the user logs in. After that the user will be taken to a main screen.

Now my problem is when the back button is pressed the user is taken to the login screen again.

Is there any way to fix this problem?

I have tried calling finish() right after startActivity() but it only made the application crash and didn't seem a good solution either.


Solution

  • In the manifest, add android:noHistory="true" as an attribute of the login activity.