Android splash screen issue


#1

Hi,
I am having an issue in the splash screen in android. Splash screen is displayed properly if the app is not running in background. But when I press back button and exits (running in background) the app and reopen the app white screen is displayed instead of the splash screen. Splash is displayed only if I removed the app from memory and open it.
Anyone facing this issue? Please help.

Crosswalk 12.41.296.5
Ionic-CLI 5.0.0
Ionic 1.0.0
cordova-plugin-splashscreen 2.1.0

config.xml has there values
< preference name=“SplashScreen” value=“screen”/>
< preference name=“SplashScreenDelay” value=“3000”/>
< splash src=“resources/android/splash/drawable-land-ldpi-screen.png” density=“land-ldpi”/>
< splash src=“resources/android/splash/drawable-land-mdpi-screen.png” density=“land-mdpi”/>
< splash…

and in app.js

$ionicPlatform.ready(function () {
setTimeout(function() {
if(navigator && navigator.splashscreen) {
navigator.splashscreenhide();
}
}, 800);


#2

It’s not an issue. Splashscreen is only shown when an app is running fresh. Bringing an app back from the memory (exiting and going back to app) doesn’t fire splashscreen plugin.

If you want to apply an event when app is resumed (brought back from background), you can use cordova events following way:

$ionicPlatform.on('resume', function() {
        
});

#3

Thanks for the quick reply. I will try it.


#4

I did something like this.
$ionicPlatform.on(‘resume’, function() {
navigator.spalshscreen.hide();
});
$ionicPlatform.on(‘pause’, function() {
navigator.spalshscreen.show();
});

It works when I press Home button or power button and then resume the app. Still get the same white screen when I press back to exit and relaunch the app. Resume does not get fired. Any thoughts?


#5

I fixed this issue by editing the splash screen plugin. Now splash screen is displayed even if it is not a fresh open. I just removed the firstShow value. Not sure if this has any side effects. But seems fine so far.


#6

I am facing the same problem @nirman99 . How did you remove firstShow value?


#7

@Ratikanta
I changed
if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) {
return;
}

to

if (HAS_BUILT_IN_SPLASH_SCREEN) {
return;
}

in /plugins/cordova-plugin-splashscreen/src/android/SplashScreen.java

that was in splash screen version 3.0.0


#8

@nirman99
Do it had any side effect?


#9

@nsvivek121
No side effects. But I think this issue was fixed in newer versions.


#10

I am using latest plugin already. I am still facing this issue.


#11

Used code from https://github.com/apache/cordova-plugin-splashscreen/blob/f6a5704dfff8eeacfd0eaf84696ee9c5f41695c4/src/android/SplashScreen.java. Now working fine. Thanks