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.由于项目时间的需要,赞改成浏览器打开下载。
  • 相关阅读:
    进度条
    html5 表单新增事件
    html5 表单的新增type属性
    html5 表单的新增元素
    html5 语义化标签
    jq 手风琴案例
    codeforces 702D D. Road to Post Office(数学)
    codeforces 702C C. Cellular Network(水题)
    codeforces 702B B. Powers of Two(水题)
    codeforces 702A A. Maximum Increase(水题)
  • 原文地址:https://www.cnblogs.com/fujinliang/p/6158324.html
Copyright © 2011-2022 走看看