Android: Splash screen issues - android

On my Android App, I have set up a splash screen. The splash screen opens when the app is opened and lasts for two seconds before it redirects to a login screen.
The issue I am having is that the splash screen displays once, and then re-directs to the login screen. BUT when I click on the app again it goes straight to the login screen ignoring the splash screen. Is there a reason for this? Does it automatically open on your last screen? Because then if I hit the back button when it opens on the login screen it DOES go back to the splash screen but then doesn't redirect to the login screen after 2 seconds.

Yes this is normal behavior. When you hit the back button after the second launch you are ending the app, thus your splash screen shows on the next launch. You will need to add an intent to your login activity's on resume method to launch your splash screen. Here is a on resume example. Android example which uses onResume, onStart and onRestart

Set clearTaskOnLaunch via the Android Manifest of your project to true. This will clear the task/stack history whenever the activity is launched.

Related

How to come back to last visible activity after splash screen on app icon click: Android

I have an application which always has to start with a splash screen.
But after the splash screen, I want that it should go to the last activity that was visible before the application went to the background.
Also, I would like the same behaviour when the app icon is clicked.
So lets say the user was on Activity5 and then he pressed the Home button.
Now if he clicks on the App icon, then the app should start with the Splash screen but then return back to Activity5.
Could someone please help me with the above?
Thanks and regards,
Sunny
For showing splash screen and starting the same activity,when user closes your app on home button pressed,you need to override the onPause() and onResume() ,of the activity . onPause() will be called when user will press the home button,Usesharedpreferences,to store some value referencing the current activity in SharedPreferences and when user comes back to your application onResume will be called
where you can retrieve the value of the variable of sharedpreferences show up the splash screen and start the same activity again.

What is function of main button on real device when quiting an app

I have noticed the splash screen does not display when user clicks the middle button on a real device to quit an application but if user selects back button from main menu to quit app and relaunches the splash screen will display.
Question is what function is the middle button performing compared to the back pressed and is there a way to ensure the splash screen is displayed when the middle button is used to quit an application.
Thanks.
The HOME button takes the user to the home screen (also called the Launcher). The BACK button by default finishes the current activity, which usually results in the user ending up on the previous activity he was in, until he reaches the home screen. The difference is BACK will explicitly finish an Activity, whereas HOME will not.

Terminate android app

I have an app with an intro screen, there will be two buttons in this screen (Ok and Cancel)
If the user clicks the cancel button the application will terminate, and if the user clicks the ok button ,the main screen appears, the main screen got a back button to go back to the intro screen.
Now, my problem is I have used
finish();
for the cancel button, and what I understood is that the 'finish()' will terminate the current running activity.
Once the application is started and if the user clicks the cancel button, the app terminates, but if the user goes to the main screen and comes back to the intro screen and then click cancel the intro screen will exit(Activity responsible for the intro screen).and the main screen appears back.
This forms a continuous loop since the previous Activity (activity opened just before the intro activity) will always appear even if the user clicks the cancel button...
Does anyone have an idea how to terminate more than one activity at a time?
You can use setResult() function in your Intro Activity, and 'catch' it in Main Activity overriding OnActivityResult() function.

how to go on previous screen from current screen in Android app

How do I go to previous screen from current screen in Android app? I know there is a back button on phone, but it takes me to beginning screen of my app and I want my buttons on app to work for going back to previous screen.
Back button indeed takes you to previously seen activity on screen, that launched the current one (not by means of back button). If back button takes you to beggining screen of your app means that navigation to your last activity was done from it. Try launching an activity from another one different from start activity.
What really can be problematic is ending application once at start activity by pressing back button and discovering the application switching to activity that lauched start activity (not by means of back button). In this case you should just call finish() inside onDestroy() listener method of your start activity.

How to start the Google home screen on Android when it's not the default?

I have a home screen replacement app. It is set via the GUI to always be used as the home screen. How can I get that activity to start the original home screen on demand? Is there a published activity name for it? I want my replacement home screen to remain the default.
The name of activity is
com.android.launcher.Launcher

Categories

Resources