android - 闪屏后,长时间显示白屏

标签 android ionic-framework ionic2

我正在使用 ionic 2。当应用程序运行时,在启动页面之后,我面对的是白屏,这需要超过 10 秒,然后我的主页才会显示。我们有什么办法可以避免这种情况吗?

配置文件:

  <?xml version='1.0' encoding='utf-8'?>
<widget id="com.ionicframework.xxxxx" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>xxxxx</name>
    <description>An awesome Ionic/Cordova app.</description>
    <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-navigation href="http://ionic.local/*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="5000" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="AutoHideSplashScreen" value="true" />
    <preference name="SplashScreenDelay" value="5000" />
    <feature name="SplashScreen">
        <param name="android-package" value="cordova-plugin-splashscreen" />
        <param name="onload" value="true" />
    </feature>
    <feature name="StatusBar">
        <param name="ios-package" onload="true" value="CDVStatusBar" />
    </feature>
    <engine name="android" spec="^6.2.3" />
    <plugin name="cordova-plugin-camera" spec="^2.4.1" />
    <plugin name="cordova-plugin-console" spec="1.0.5" />
    <plugin name="cordova-plugin-device" spec="1.1.4" />
    <plugin name="cordova-plugin-nativestorage" spec="^2.2.2" />
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.1" />
    <plugin name="cordova-plugin-statusbar" spec="2.2.1" />
    <plugin name="cordova-plugin-whitelist" spec="1.3.1" />
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
</widget>

Package.json:

{
    "name": "ionic-hello-world",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "2.2.1",
        "@angular/compiler": "2.2.1",
        "@angular/compiler-cli": "2.2.1",
        "@angular/core": "2.2.1",
        "@angular/forms": "2.2.1",
        "@angular/http": "2.2.1",
        "@angular/platform-browser": "2.2.1",
        "@angular/platform-browser-dynamic": "2.2.1",
        "@angular/platform-server": "2.2.1",
        "@ionic/storage": "1.1.7",
        "angularfire2": "^2.0.0-beta.7",
        "cordova-android": "^6.2.3",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-console": "1.0.5",
        "cordova-plugin-device": "1.1.4",
        "cordova-plugin-nativestorage": "^2.2.2",
        "cordova-plugin-splashscreen": "~4.0.1",
        "cordova-plugin-statusbar": "2.2.1",
        "cordova-plugin-whitelist": "1.3.1",
        "firebase": "^3.6.9",
        "geofire": "^4.1.2",
        "ionic-angular": "2.0.0",
        "ionic-native": "2.4.1",
        "ionic-plugin-keyboard": "~2.2.1",
        "ionic2-rating": "^1.2.0",
        "ionicons": "3.0.0",
        "ng2-translate": "^5.0.0",
        "rsvp": "^3.4.0",
        "rxjs": "5.0.0-beta.12",
        "sw-toolbox": "3.4.0",
        "zone.js": "0.6.26"
    },
    "devDependencies": {
        "@ionic/app-scripts": "^1.3.7",
        "@ionic/cli-plugin-cordova": "1.1.2",
        "@ionic/cli-plugin-ionic-angular": "1.1.2",
        "typescript": "2.0.9"
    },
    "cordovaPlugins": [
        "cordova-plugin-whitelist",
        "cordova-plugin-console",
        "cordova-plugin-statusbar",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "ionic-plugin-keyboard"
    ],
    "cordovaPlatforms": [],
    "description": "xxxx: An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-nativestorage": {},
            "cordova-plugin-camera": {}
        },
        "platforms": [
            "android"
        ]
    }
}

最佳答案

将您的 splasscreendelay 值设置为 20000 并删除 autohidesplashscreen 首选项。在您的 app.component.ts 中隐藏平台准备就绪的启动画面。在你的 app.component.ts 中

import { SplashScreen } from '@ionic-native/splash-screen';
import { Platform} from 'ionic-angular';
constructor(splashScreen: SplashScreen,platform: Platform){
    platform.ready().then(() => {
          splashScreen.hide();
     });
}

关于android - 闪屏后,长时间显示白屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44124191/

相关文章:

android sqlite orderby datetime 总是获取第一行

javascript - ionic +sqlite 在浏览器中工作但在真实设备上出现 TypeError

http - http请求调用方法的难点

sqlite - 使用 Azure 移动应用程序的 ionic 2 离线数据同步抛出 TypeError :Cannot read property 'openDatabase' of undefined

Angular 2 : NgFor without HTML Tag?

android - 授予应用程序root权限

Android触摸方向为西北,东北为UP方向

java - 使用 aSmack 客户端映射 Openfire 自定义插件

angularjs - Ionic v1 中的 img src 路径

angular - 隐藏选项卡 - 在特定选项卡上突出显示 Ionic 3