Can a Flex AIR app on Android start up as a service on boot?
I understand you can create a service in Android and start it up on boot, which can then be used to get location updates, communicate with a server, etc.
However what I wanted to find out is if this possible to do in AIR. AIR runs on Android, but can it be set a 'service' and start up on boot (sitting 开发者_开发技巧in the background
)?
Thank you!
Your application will be running inside the AIR runtime which itself is not a service. So the short answer is unfortunately no.
Also the AIR runtime is a whopping 16MB
, so you (and more so your users) are better if you write a native Android Service.
Yes, it's possible. Place this code inside application.xml
<application>
<activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:enabled="true" android:name="packeg.and.Class"
android:exported="true"
android:permission="android.permission.WHAT_YOU_NEED"
>
<intent-filter android:priority="999" >
<action android:name="android.provider.some.SERVICE" />
</intent-filter>
</receiver>
<activity android:name="your.package.MainActivity">
</activity>
</application>
Of course you first need to write Java code and later make ANE file.
精彩评论