In my app, I would like to run the Splash screen once at first run only but the problem is that I already placed in the Manifest
this line: android:noHistory="true"
which works great if I press back button and exits the app but note that the app is still in the background running, and when I press the app icon it goes back again to the Splash screen then my Registration page. I wanted to be redirected to the Registration page directly when I reopen my application.
How do I do this? Thanks ahead for any suggestions.
This is how I achieved it!Hope it helps!
The simplest way it that You can use android:noHistory="true" in your manifest file.
You can use Shared Preferences to save some boolean when you run your app at very first launch and then check that value on every launch if exits then directly start the Registration Activity.
So in that case you need to change the logic litle bit by saving the app version and check for app version on every launch in that way you will be able to produce real user experience.
Have a look at this : How to create a one-time welcome screen using Android preferences?
To elaborate on the mention of "shared preferences", I believe the following would work, if you inserted it in onCreate() of your main activity:
After the block executes, "firstTime" should indicate whether this is the first time the app has been run. "appInfo" is just a placeholder name for whatever you want the preferences file to be called, I believe.
So here's what I did, in my SplashActivity(onCreate):
SplashActivity(onResume):
In my RegistrationActivity(onCreate):
And then disabled back button to prevent going back unless the user presses Home:
Big thanks for those that contributed!