Extending Adobe AIR


Android details

On Android, two extension models are supported: Java archives for extensions developed with the Android SDK, and shared libraries for those developed with the Native Development Kit (NDK). Both are appropriate for some set of extensions; simply pick the one that best suits your use case. (One can, of course, use JNI to bridge between Java and native code on Android, should that also be necessary.)

Android上支持两种扩展模型:Android SDK开发的Java archives,NDK开发的shared libraries。(也可以通过JNI桥接Java和native code)

On Android, resources such as images are compiled into each application and accessed via constants in the generated class R. This mechanism doesn't support composition; there is only one instance of R available. Android extensions can include resources but, to work around this limitation, they must be accessed via an API provided by the runtime.


To include resources in your Android extension, first place them in the "res" subdirectory of the Android platform directory, using the same naming conventions and file structure as for a regular Android application. At packaging time, resources from all extensions are merged into the resources directory of the main application. In order to avoid name conflicts, extensions should use a unique prefix for their resources.

为了在你的Android扩展中包含资源,首先把它们直接放在Android platform的res子目录,使用与通常Android程序一样的命名规则和文件结构。打包的时候,所有扩展的资源被合并到主程序的resource目录。为了避免名字冲突,扩展应该为它们的资源使用唯一的前缀。

These resources will be merged, as will the code in the Java archive, into the compiled dex and resources files of the main application. They can then be accessed via the FREContext.getResourceId() method, which takes the desired resource ID as an argument. In other words, instead of accessing an image as, for example, R.drawable.background_image, use getResourceId( "drawable.background_image" ).

Note that this API is available only in Java, as the Android resource mechanism is a Java construct, not expected to be accessed by extensions using native Android development.

The Java FREContext class also provides, on Android only, a getActivity() method that returns the main application Activity, which in turn is required by a variety of Android APIs.

个人分类: Adobe
想对作者说点什么? 我来说一句


2015年08月11日 145KB 下载