Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Ionic 2:缩短应用程序启动时间_Android_Ios_Mobile_Ionic2_Splash Screen - Fatal编程技术网

Android Ionic 2:缩短应用程序启动时间

Android Ionic 2:缩短应用程序启动时间,android,ios,mobile,ionic2,splash-screen,Android,Ios,Mobile,Ionic2,Splash Screen,我必须建立一个离子应用程序,我真的需要减少启动时间。 目前,为了纪念6x pro,我等了14秒 我尝试使用 ionic run android --prod 但没什么不同 我使用的是Ionic v2.1.8 我真的不知道我能做什么,但是14秒有点太长了。有人有主意吗 ps:我正在main.ts文件中调用enableProdMode() import { NgModule, enableProdMode } from '@angular/core'; enableProdMode(); 我的

我必须建立一个离子应用程序,我真的需要减少启动时间。 目前,为了纪念6x pro,我等了14秒

我尝试使用

ionic run android --prod
但没什么不同

我使用的是Ionic v2.1.8

我真的不知道我能做什么,但是14秒有点太长了。有人有主意吗

ps:我正在main.ts文件中调用enableProdMode()

import { NgModule, enableProdMode } from '@angular/core';

enableProdMode();
我的app.component.ts文件:

import {Component} from '@angular/core';
import {Platform, ViewController, App, AlertController} from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import {LoginPage} from "../pages/login/login";
import {PData} from "../providers/p-data";
import {CNotification} from "../classes/CNotification";
import {PTranslate} from "../providers/p-translate";
import {CheckUserPage} from "../pages/check-user/check-user";

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage = CheckUserPage;
  display_handled : boolean = false;
  diplayed_notifications_handled: CNotification[] = [];
  position : number = 0;

  constructor(public platform: Platform, public pdata: PData, public translate: PTranslate, public app: App, public alertCtrl: AlertController) {
    platform.ready().then(() => {
      StatusBar.styleDefault();
      Splashscreen.hide();
    });

    platform.registerBackButtonAction(() => {
      let nav = app.getActiveNav();
      let activeView: ViewController = nav.getActive();

      if(activeView != null){
        if(nav.canGoBack()) {
          nav.pop();
        } else{
          let alert = this.alertCtrl.create({
            title: this.translate.get("close-appFine"),
            message: this.translate.get("sure-want-leave"),
            buttons: [
              {
                text: this.translate.get("yes"),
                role: 'cancel',
              },
              {
                text: this.translate.get("yes"),
                handler: () => {
                  this.platform.exitApp();
                }
              }
            ]
          });
          alert.present();
        }
      }
    });
  }

  display(range: number = 5) : void {
    let keys = this.pdata.keysGetter(this.pdata.notifications_handled).reverse();
    let index : number = this.position;
    for(index; index < this.position + range && index < keys.length ; index++) {
      let guid : string = keys[index];
      let notification : CNotification = this.pdata.notifications_handled[guid];
      this.diplayed_notifications_handled.push(notification);
    }
    this.position = index;
    this.display_handled = true;
  }

  doInfinite(infiniteScroll) {

    setTimeout(() => {
      this.display();
      infiniteScroll.complete();
    }, 500);
  }
}
从'@angular/core'导入{Component};
从“ionic angular”导入{Platform、ViewController、App、AlertController};
从“离子本机”导入{StatusBar,Splashscreen};
从“./pages/login/login”导入{LoginPage};
从“./providers/p-data”导入{PData}”;
从“./classes/CNotification”导入{CNotification};
从“./providers/p-translate”导入{PTranslate}”;
从“./pages/check user/check user”导入{CheckUserPage};
@组成部分({
templateUrl:'app.html'
})
导出类MyApp{
rootPage=CheckUserPage;
显示处理:布尔=假;
已处理的显示通知:CNotification[]=[];
位置:编号=0;
构造函数(公共平台:平台,公共pdata:pdata,公共翻译:PTranslate,公共应用程序:应用程序,公共警报Ctrl:AlertController){
platform.ready()。然后(()=>{
StatusBar.styleDefault();
Splashscreen.hide();
});
平台注册表BackButtonAction(()=>{
让nav=app.getActiveNav();
让activeView:ViewController=nav.getActive();
如果(activeView!=null){
if(导航canGoBack()){
nav.pop();
}否则{
让alert=this.alertCtrl.create({
标题:this.translate.get(“close appFine”),
消息:this.translate.get(“确定要离开”),
按钮:[
{
text:this.translate.get(“是”),
角色:“取消”,
},
{
text:this.translate.get(“是”),
处理程序:()=>{
this.platform.exitApp();
}
}
]
});
alert.present();
}
}
});
}
显示(范围:编号=5):无效{
让keys=this.pdata.keysGetter(this.pdata.notifications_handled).reverse();
let index:number=this.position;
对于(index;index{
这个.display();
无限滚动。完成();
}, 500);
}
}

我通过更新Ionic v3解决了这个问题,正如Andreas Gassmann所示,实现了延迟加载,如图所示,并使用--prod选项构建。在设备中,加载时间已从12秒以上变为4秒以下。

我通过更新Ionic v3解决了这个问题,正如Andreas Gassmann所示,实现了延迟加载,如图所示,并使用--prod选项构建。在设备中加载时间已从12秒以上变为4秒以下。

请添加
app.component.ts
文件的内容好吗?所以我们可以看看应用程序启动时发生了什么…更新后。但我不知道为什么重要?提供你的离子信息输出。是否可以将爱奥尼亚的版本升级到新版本?它目前已经在3.4.0中,使用Angular 4(我猜2.1仍然使用Angular 2,它没有一些改进)。当然,我已经考虑过了。但我担心升级会干扰我所有的应用程序。如果你升级到Ionic v3,你可以将延迟加载添加到你的应用程序中。这将进一步提高加载速度,但需要在应用程序中进行大量更改。请添加
app.component.ts
文件的内容,好吗?所以我们可以看看应用程序启动时发生了什么…更新后。但我不知道为什么重要?提供你的离子信息输出。是否可以将爱奥尼亚的版本升级到新版本?它目前已经在3.4.0中,使用Angular 4(我猜2.1仍然使用Angular 2,它没有一些改进)。当然,我已经考虑过了。但我担心升级会干扰我所有的应用程序。如果你升级到Ionic v3,你可以将延迟加载添加到你的应用程序中。这将进一步提高加载速度,但需要在应用程序中进行大量更改。