2015-08-14 129 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")); 
    } 
} 
相關問題