AIR 自动更新详解

 

AIR 1.5 加入了自动升级的类air.update.ApplicationUpdater,这样你的AIR应用程序便可以通过网络自动更新到最新版本了。

注意:Flex SDK 3.2以上才支持AIR 1.5,Flex SDK 4.0运行可能会有报错。建议采用Flex SDK3.4。

自动更新的原理:ApplicationUpdater 会去读取网络上的一个XML版本描述文件,其中包含了版本号和对应的安装文件路径以及更新描述信息,然后和当前运行的AIR程序版本进行比较,来决定是否下载和安装。

这里有一个例子:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="checkForUpdate()">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import air.update.events.UpdateEvent;
			import air.update.ApplicationUpdaterUI;
			private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI();

			private function checkForUpdate():void {
				appUpdater.updateURL = "http://localhost:8400/team/xml/test-update.xml"; // Server-side XML file describing update
				appUpdater.isCheckForUpdateVisible = false; // We won't ask permission to check for an update
				appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate); // Once initialized, run onUpdate
				appUpdater.addEventListener(ErrorEvent.ERROR, onError); // If something goes wrong, run onError
				appUpdater.initialize(); // Initialize the update framework
			}  
			private function onError(event:ErrorEvent):void {
				Alert.show(event.toString());
			}
			private function onUpdate(event:UpdateEvent):void {
				appUpdater.checkNow(); // Go check for an update now
			}
		]]>
	</mx:Script>
</mx:WindowedApplication>
 

creationComplete=”checkForUpdate()”表示在程序加载完成后会连接到更新服务器上自动监测新版本。
服务器上的XML文件(test-update.xml)内容如下:

<?xml version="1.0" encoding="utf-8"?> 
<update xmlns="http://ns.adobe.com/air/framework/update/description/1.0"> 
    <version>v1.1</version> 
    <url>http://localhost:8400/team/update/test.air</url> 
<description>update</description> 
</update> 
 



注意:XML中的版本号和指定的AIR程序的版本号一定要保证匹配。
请使用发行版本来测试,调试版本不支持升级安装。

当然,你可以可以采用第三方类包来简化开发流程:
下载everythingflex的类包: everythingflexairlib.swc 把类包copy到你工程的libs文件夹。
地址:http://everythingflexairlib.googlecode.com/files/everythingflexairlib.swc

这里有一个例子:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script> 
        <![CDATA[ 
            import com.everythingflex.air.managers.UpdateManager; 
            private var updateManager:UpdateManager = new UpdateManager("http://localhost:8400/team/test-update.xml",false); 
        ]]> 
    </mx:Script> 
    <mx:Button click="updateManager.checkForUpdate()" label="Test for Update" 
        horizontalCenter="0" verticalCenter="0"/> 
</mx:WindowedApplication> 
 



其中UpdateManager构造函数第2个参数代表是否自动检测新版本,TRUE为是,FALSE为否。

<?xml version="1.0" encoding="utf-8"?>
<currentVersion version="v1.1"
	downloadLocation="http://localhost:8400/team/update/test.air"
	forceUpdate="false" message="Added new features" />
 


同上,你还需要一个放在服务器上的XML文件,告知程序要更新到哪一个版本:

其中:downloadLocation是更新程序的路径,forceUpdate表示是否弹出警告框来提示用户更新程序,message是警告框中的详细信息。


开发过程可能遇到的错误代码列表:
16800 Occurs during validating the downloaded update file. The subErrorID may contain additional information.
16801 Invalid Adobe AIR file (missing application.xml).
16802 Invalid Adobe AIR file (missing mimetype).
16807 Invalid Adobe AIR file (format).
16804 Invalid Adobe AIR file(invalid flags).
16805 Invalid Adobe AIR file(unknown compression).
16806 Invalid Adobe AIR file (invalid filename).
16807 Invalid Adobe AIR file (corrupt).
16808 Configuration file does not exist.
16809 updateURL not set.
16810 Reserved.
16811 Invalid configuration file(unknown configuration version).
16812 Invalid configuration file (URL missing).
16813 Invalid configuration file (delay format).
16814 Invalid configuration file (invalid defaultUI values).
16815 Invalid update descriptor (unknown descriptor version).
16816 Invalid update descriptor (missing update version).
16817 Invalid update descriptor (invalid description).
16818 IO error while saving data to disk. subErrorID may provide more information.
16819 Security error while downloading. subErrorID may provide more information.
16820 Invalid HTTP status code. subErrorID may contain the invalid status code.
16821 Reserved.
16822 IO error while downloading. subErrorID may provide more information.
16823 EOF error while saving data to disk. subErrorID may provide more information.
16824 Invalid update descriptor. subErrorID may provide more information.
16825 The update file contains an application with a different application ID.
16826 The update file does not contain a newer version of the application.
16827 The version contained in the update file does not match the version from the update descriptor.
16828 Cannot update application, usually because the application is running in the AIR Debug Launcher (ADL).
16829 Missing update file at install time.

 

--虾米

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 很高兴为您回答这个问题。 在 2018 年发布的 MacBook Air 上安装 macOS Ventura 的体验可能会很好,因为这款电脑具有足够的硬件性能来运行 macOS Ventura。 在安装操作系统时,您应该注意按照正确的步骤操作,并确保在安装过程中不会发生意外中断。如果您遇到任何问题,可以尝试搜索网上的解决方案或者联系 Apple 支持人员协助解决。 一般来说,在 2018 年的 MacBook Air 上安装 macOS Ventura 应该是一个较为顺利的过程。希望这些信息对您有所帮助。 ### 回答2: 作为一位对MacBook Air 2018使用及更新macOS Ventura有一些经验的用户,我可以说这次更新给我带来了很好的体验。 首先,macOS Ventura为MacBook Air带来了许多新的功能和改进。其中包括新的设计风格、更加优化的界面交互以及更好的性能表现。我发现系统的响应速度更快,打开应用程序和文件的速度都有所提升,整体使用起来更加流畅。 另外,macOS Ventura还加强了与其他Apple设备的互通性。通过增强的无缝连接功能,我可以更方便地在MacBook Air和iPhone或iPad之间进行文件传输和共享。这对于日常工作和学习非常方便,我可以随时将照片、文档和笔记等内容传输到不同设备上进行编辑和浏览。 此外,macOS Ventura还引入了一些有用的新工具和应用程序。例如,更新后的Safari浏览器增加了更多的隐私保护功能和更强大的网页浏览性能,令我在上网时感到更加安全和舒适。另外,新版的照片应用程序带来了更丰富的编辑功能和智能组织,让我能够更好地管理和美化我的照片库。 总的来说,我对MacBook Air 2018更新macOS Ventura的体验非常满意。这次更新提供了许多实用的新功能和改进,让我的使用体验更加顺畅和高效。我相信这次更新将进一步提升MacBook Air的性能和功能,为我带来更多便利和愉悦的使用体验。 ### 回答3: MacBook Air 2018更新macOS Ventura后的体验非常出色。Ventura是苹果最新的操作系统版本,为用户带来了许多新的功能和改进。 首先,Ventura针对MacBook Air 2018的硬件进行了优化,提高了整体性能和效率。这使得我的MacBook Air在运行各种任务时更加流畅,并且启动和关机时间也大大缩短。 其次,Ventura带来了全新的界面设计和改进的用户体验。我发现新的界面更加现代化和美观,使用起来非常直观和方便。新的通知中心、控制中心和Spotlight搜索功能也更加强大,使得我能更快捷地访问和管理我的文件和应用程序。 此外,通过Ventura,我可以更好地与其他苹果设备进行互动。例如,我可以使用AirDrop功能轻松地在MacBook Air和我的iPhone之间传输文件和照片,而且无缝切换功能也让我能够更方便地在我的苹果设备之间切换。 最后,Ventura还加强了Mac的安全性和隐私保护。新的授权功能、数据共享控制和加强的防止跟踪功能都使得我的MacBook Air更安全可靠。 总的来说,MacBook Air 2018更新macOS Ventura的体验非常好。我非常满意Ventura带来的诸多改进,使得我的MacBook Air在性能、用户体验和安全性方面都得到了提升。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值