2015-08-14 126 views
1

我想创建基于Adobe Air的Android应用程序的更新机制。在我的私人小应用程序观众的特殊情况下,我使用我的应用程序apk文件的直接分发(无需Google Play,通过在用户设备上安装Phisical)。但我也需要能够自动安装更新(假设它将是我应用UI中的“检查更新”按钮)。任何人都可以帮助我完成这项任务吗?我如何创建这个?从另一个Adobe Air应用程序启动Adobe AIR应用程序文件(* .apk)

现在我有这样的想法: 我试图用我的应用程序下载文件(使用加载程序并使用File api编写文件)到用户存储器...然后我想使用任何Air Native Extension启动该文件。有没有创建ANE来做到这一点?

回答

0

在我的情况下,为了创建自动更新机制,我从app.xml获取了本地版本号,并从服务器获得了最新的编号。 这是我的设置。

app.xml的

... 
<name>mysomeapp</name> 
<!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade. 
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value. 
An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . --> 
<versionNumber>1.0.1</versionNumber> 
... 

动作

private var appVersion: String; 
public function init():void 
{ 
    // Get local versionnumber from app.xml 
    var appDescriptor:XML = NativeApplication.nativeApplication.applicationDescriptor; 
    var ns:Namespace = appDescriptor.namespace(); 
    appVersion = appDescriptor.ns::versionNumber; // In this case, it returns "1.0.1". 

    // Get latest versionnumber from server 
    var httpservice: HTTPService = new HTTPService(); 
    httpservice.url = "http://myserver/foobar/version"; 
    httpservice.method = URLRequestMethod.GET; 
    httpservice.addEventListener(ResultEvent.RESULT, checkVersionResult); 
    httpservice.send(); 
} 

public function checkVersionResult(e: ResultEvent): void 
{ 
    // Compare latest number with local number. 
    if (e.result != appVersion) 
    { 
     // If the local version is not latest, download latest app from server. 
     navigateToURL(new URLRequest("http://myserver/foobar/androidAppDownload")); 
    } 
} 
相关问题