简体   繁体   中英

Hiding Android Splash screen in Capacitor Ionic/Ionic React

I'm having issues with the Ionic Capacitor Splashscreen. I've tried to use the official documentation which can be found here . However none of the examples in the documentation seem to run at all for me.

Just an example of what I've tried is this bit of code inside my capacitor.config.json:

"plugins": {
   "SplashScreen": {
     "launchShowDuration": 10000,
     "backgroundColor": "#ff00ff"
   }
 }

The app behaves exactly as it did prior, which is probably the default setting (splash showing for 3 seconds after which the app loads).

I have also tried to disable autohide among other things, but none of the code seems to actually do much of anything, the app still runs as it did before. Any ideas?

You can use Plugins.SplashScreen.hide method of Capacitor, I explained it in this answer: https://stackoverflow.com/a/62063934/6695569 .

import { SplashScreen } from '@capacitor/splash-screen';

// Hide the splash (you should do this on app launch)
await SplashScreen.hide();

// Show the splash for an indefinite amount of time:
await SplashScreen.show({
  autoHide: false
});

// Show the splash for two seconds and then automatically hide it:
await SplashScreen.show({
  showDuration: 2000,
  autoHide: true
});

https://capacitorjs.com/docs/apis/splash-screen?#example

Note: if you use your device check your wifi if the same with your laptop

 ´ionic capacitor run android -l --host=**192.168.X.XX**´ <br>
 ´ionic capacitor run android -l --host=**ADDRESS_IP**´

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM