Question

i am working in mobile application using Flash 6 Air , AS3 , i want to know whether there is any possibility to make the auto update feature , when ever the user open the app , it goes to see for update .

so could you please help me on this requirement and give me the code that I have to use ?!!

thanks in advance.

Was it helpful?

Solution

there's two options here

  1. Upload your app to the Google Play Store, everytime you update your app, increase the version number, upload the new version and Google will handle it for you.
  2. The more complicated option is to write your own update downloader + a native extension to tell the operating system to launch the .apk file.

A sample downloader

    public function start():void
    {
        var fileLoader:URLLoader = new URLLoader
        fileLoader.dataFormat = URLLoaderDataFormat.BINARY;
        fileLoader.addEventListener(Event.COMPLETE,downloadSuccess);
        var url:URLRequest = new URLRequest("http://www.example.com/updates/"+targetVersion+".apk");
        fileLoader.load(url);
    }
    private function downloadSuccess(event:Event):void
    {
        var fileLoader:URLLoader = event.target as URLLoader;
        fileLoader.removeEventListener(Event.COMPLETE,downloadSuccess);
        var fs:FileStream = new FileStream();
        var file:File = File.userDirectory.resolvePath(targetVersion+".apk");
        fs.open(file,FileMode.WRITE);
        fs.writeBytes(fileLoader.data);
        fs.close();
//insert native extension call here.
    }

Then you'll need an ANE to trigger the android package installer. There are plenty of ANE tutorials out there, though none that cover specifically what you want. I recommend starting with this one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top