应用操作

启动应用,安装应用
牛刀小试
下载应用
安装应用
启动应用
示例代码
//获取应用相关的目录,android和ios的目录结构不同
//android下可以存储在 /sdcard/download下面
//ios只能存储在应用里面
app.getAppDirectoryEntry(function(res){
    //区分平台,并将相应的目录保存到全局,方便下面下载的时候使用
    if(window.devicePlatform=="android"){
        window.savePath=res.sdcard;                     
    }else if(window.devicePlatform=="iOS"){
        window.savePath=res.documents;
    }
});
var uri=encodeURI("http://dev.bingocc.cc:8060/bingotouch-fileserver/com.bingo.btlink_1.apk");
var filePath=window.savePath+"/com.bingo.btlink_1.apk";

$("#btnDownloadApp").tap(function(){

    app.progress.start("温馨提示","文件下载中...");
    var fileTransfer=new FileTransfer();
    fileTransfer.download(
        uri,
        filePath,
        function(entry){
            app.progress.stop();
            app.hint("下载完成!");
            //将文件路径保存起来,方便后面调用
            window.appFileUri=entry.fullPath;
            $("#ao_result").html("path:"+entry.fullPath);
        },
        function(error){
            app.progress.stop();
            app.hint("下载失败");
            $("#ao_result").html(JSON.stringify(error));
        }
    );
});

$("#btnInstallApp").tap(function(){
    //just for android
    app.install(filePath);
});

$("#btnRunApp").tap(function(){
     app.run("com.bingo.btlink");
});