This could be because the app is not terminated, but still running in the background. So, if you click the app icon, the running instance is brought to the foreground.
Hi LouisR, I use the exact code from the above but it is for ios. I think the “SplashScreenDelay”'s value is too high, if my memory serves me right I tried to give it a large value and it caused the app to crash or stop.
@arjenbroeze indeed you are right. On Android, if I just tap the ‘back’ button, the app is not really terminated.
How can I make it so ?
Thanks
@KimB
I saw somewhere in the forum that it was recommended to use a long delay : <preference name="SplashScreenDelay" value="10000"/>
and to hide the splash screen manually with: $cordovaSplashscreen.hide();
I think the default behaviour of IONIC is to close the app if the back button is pressed and you’re at the beginning of the view history. Is there something in your code maybe that prevents this from happening?
Currently not much time, but on Android it is possible to close the application explicitly by using “navigator.app.exitApp()”. You can either put this behind a button in your app, or hack the back button in the “ready” event. If you need an example, just let me know.
The above code does interfere with other back behaviour I used. Here is the code I use to change the behaviour depending upon the current view:
// Change the behaviour of the Back button
$ionicPlatform.registerBackButtonAction(function (event) {
switch($state.current.name) {
case "tabs.home":
navigator.app.exitApp();
break;
case "tabs.charts":
case "tabs.sessions":
case "tabs.analytics":
event.preventDefault();
break;
default:
navigator.app.backHistory();
}
}, 100);
I may have been hasty when I stated “The above code does interfere with other back behaviour”. Testing shows it seems to work but I still prefer the code from my last comment. Interestingly, I still have the problem where I only get the splash on first launch. If I close the app using the Android Recent Apps list, the splash does show on the next launch.
navigator.app.exitApp() does not seem to completely remove the app from memory. Is there an ionic command to completely “terminate” the app?