zoukankan      html  css  js  c++  java
  • cordova 下载更新

    function UpdateForAndroid(downloadUrl) {
    $ionicLoading.show({
    template: "已经下载:0%"
    });
    var targetPath ="file:///storage/sdcard0/Download/yuetui.apk";
      var trustHosts = true;
    var options = {};
    $cordovaFileTransfer.download(downloadUrl, targetPath, options, trustHosts).then(function (result) {
    $cordovaFileOpener2.open(targetPath, 'application/vnd.android.package-archive'
    ).then(function () {
    // 成功
    }, function (err) {
    console.log(err);
    });
    $ionicLoading.hide();
    }, function (err) {
    $ionicLoading.show({
    template: "下载失败"
    });
    $ionicLoading.hide();
    }, function (progress) {
    $timeout(function () {
    var downloadProgress = (progress.loaded / progress.total) * 100;
    $ionicLoading.show({
    template: "已经下载:" + Math.floor(downloadProgress) + "%"
    });
    if (downloadProgress > 99) {
    $ionicLoading.hide();
    }
    });
    });
    }
    网上找的这种方式,能实现APP的下载更新,但存在些问题,
    1.存在SD卡的情况下,不会自已更新完后,打开APP,
    2.可能没有存在SD卡的情况下,需要判断。
    3.目前大部分APP都有用的android系统默认的下载安装器downloadmanager,cordova没找到此类方式(考虑写一个)
    4.由于项目时间的需要,赞改成浏览器打开下载。
  • 相关阅读:
    .net注册iis
    hdu 1081To The Max
    hdu 1312Red and Black
    hdu 1016Prime Ring Problem
    hdu 1159Common Subsequence
    hdu 1372Knight Moves
    hdu 1686Oulipo
    hdu 1241Oil Deposits
    hdu 1171Big Event in HDU
    hdu 4006The kth great number
  • 原文地址:https://www.cnblogs.com/fujinliang/p/6158324.html
Copyright © 2011-2022 走看看