I have developed an android apps that have a splash screen and a login page. The problem is when a user give credential and pressed log in button it open controlActivity. but when I pressed back button, I navigate to login page again If I pressed back button again I navigate to splash screen. How can I stop navigating to previous page, when user press back button then app should exit?
Question posted in Android Studio
The official documentation can be found here.
The official documentation can be found here.
3
Answers
You need to put a flag in the activity you want to be forgotten.
Why does it happen ?
This is happening because whenever you open another activity from intent, it creates it over it.
How to solve the problem?
OR
If you want to close the app
onBackPressed
, you can override the method. Add this to your activity.Doing this, the app will be closed on back pressed!
Answer by @Sambhav Khandelwal should solve your problem. In your splash screen you need to do add flags with intent like:
Or you can do without flags like below: