After I saw some tweets about issues related to accessing the Wi-Fi network from an AIR application running on Android I thought it would be worth writing a post about this topic.
If you have installed an Android application on your phone you know that during this process you are presented with a screen stating what permissions the application you are about to install will use: network communication, contact data, location, storage, and so on.
I think this is a good thing especially when dealing with applications from “not so trusted” sources. You have a last chance to decide if you are willing to install that app or not. Thus it is only natural Android apps built with Adobe AIR to follow the same rules. One more thing on security/permissions: I think it is a best practice, as a developer, to request the minimum permissions required for your application.
The way you set up these permissions is quite simple: you add an <android> node to your application descriptor file having the <application> node as the root (the application descriptor file is the XML file you already use for setting the different configuration options for your AIR application – application name, enabling the update framework, initial size and position, and so on). Here is an example:
Later Edit:
<android>
<manifestAdditions>
<manifest>
<attribute name="android:installLocation" value="auto"/>
<data>
<![CDATA[
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
]]>
</data>
</manifest>
</manifestAdditions>
</android>
My colleague Ashutosh Sharma kindly pointed out that this mechanism was slightly changed recently:
<android>
<manifestAdditions>
<![CDATA[
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-configuration android:reqFiveWayNav="true"/>
<supports-screens android:normalScreens="true"/>
<uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch"/>
<application android:enabled="true">
<activity android:excludeFromRecents="false">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity>
</activity>
</application>
</manifest>
]]>
</manifestAdditions>
</android>
In this example I added an additional setting in the form of android:installLocation=”auto” as the attribute for the <manifest> node in order to allow the user to install the application either on the internal memory or on the SD memory card. The same way you can add additional permissions supported by the Android OS.
Now, next time when you have problems accessing resources from your AIR app on Android, you should know that this is the first thing to look for.





