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.由于项目时间的需要,赞改成浏览器打开下载。
  • 相关阅读:
    [转载]memcached完全剖析--1. memcached的基础
    I/O多路复用
    How to install the zsh shell in Linux && how to set it as a default login shell
    深入理解计算机中的 csapp.h和csapp.c
    (一)网络编程基础之套接字入门
    crx
    t
    武汉第一例肺炎病例
    C语言 ## __VA_ARGS__ 宏
    NLP之中文分词cppjieba
  • 原文地址:https://www.cnblogs.com/fujinliang/p/6158324.html
Copyright © 2011-2022 走看看