Did you finally found a solution?
According to that:
we should be able to execute task in background. But not any of my events (ENTER_FRAME, TIMER or SOUND_COMPLETE) are fired. SetTimeout neither.
Flex SDK 4.6 / AIR 3.4 / FlashDevelop / Windows 7
Please let me know if you have found something.
AIR 3.3 onwards, action script developers can execute short task in the background along with audio playback and location updates on iOS. In order to execute task in background, you would need to set
1) NativeApplication.nativeApplication.executeInBackground = true (in action script)
2) swf version should be 16 or more
3) namespace should be 3.3 or more (in application descriptor)
Please confirm if you have used the above settings in your app.
I have NativeApplication.nativeApplication.executeInBackground = true in my Main.as
I also turn this property to true on NativeApplication.nativeApplication Event.DEACTIVATE
I compile with -swf-version=17 in my compiler options.
I use namespace 3.4 in the manifest.
I do my tests under iOS 6 on iPad 2, iPhone 4, iPhone 5, Acer Iconia tab/Android
And in my iOS manifest:
I also tried with AIR 3.5 beta/-swf-version=18. Same issue on both Android and iOS.
Do you confirm that should work? Or am I trying to do something impossible?
Because this page says Bakground "networking". Do that mean only the pre-background loader.load calls are working in background?
Pease confirm if you are using renderMode direct or gpu in the manifest?
If renderMode is set to direct or gpu, execution in background won't be allowed on both Android and iOS.
Yes I'm using Starling so I have renderMode set to direct.
There's definitely no way to do background tasks using Stage3D?
Could you please reply to my last message?
With Stage3D, you have to use renderMode direct and as i have mentioned earlier execution in background won't be allowed on Android and iOS in this case.
You might want to raise a feature request for this issue.
Nehgupta, Is it possible to change the render mode during the execution of an application? As in when a user "deactivates"/"activates" the app, can the render mode be switch as to allow background execution?
As far as I know, you can not change the renderMode dureing execution. Only in the manifest when compiling.
I am facing the same behaviur, my app work fine in foreground but when I move to backgroud they go to sleep.
When the app go to background I need to execute a http process each 15 secs, i read a lot threads without find any solution.
Anyone have a solution to work a simple http process in background, like how work skype?
I agree it seems to be the case that renderMode can't be programatically changed. What is the reason that Stage3D can't support background location/audio tasks?
It's seriously crap that background execution isn't supported with 'direct' renderMode. Apart from some obscure messages on the forums like this there is nothing I've found to document that this is the case.
Adobe : I would suggest that if AIR is to become a genuine mobile framework this is one of the issues that must be resolved.
I totally agree with you and I advise you to vote and comment the new "feature request" I raised here:
That will encourage Adobe to find a solution.
This should be great but I think adobe isn't work enough to provide a real mobile framework, this lack of information confirm that.
Anyone can suggest me a workaround about the backrgound http proccess for a IOS app ?
I already try a few workaround with the same result, the background process isn't work.
I think isn't possible to run a simple http process in background on IOS.
This is a terrible news for my app because they already work fine on android and playbook but how isn't possible to do on IOS?
Any one have a new suggestion:
So far as I understand it only location and audio updates are available in the background on IOS... you may be able to trick your app into working if you hooked into one of these but it might be a bit of a long shot.
What we're complaining about above is that even though location and audio events are meant to be supported in IOS and Android, when the renderMode is changed to 'direct' this is not the case...
Background processing does not work if renderMode direct is used and it holds true for both iOS and Android.
Please confirm if you have set "NativeApplication.nativeApplication.executeInBackground" to true in your application?
You might want to refer this link for details on AIR iOS background behavior.
You might want to tell your posse down at Adobe that renderMode direct needs to be supported for background mode.
Serious failing otherwise.
This is from adobe : Supporting background tasks on iOS
Adobe AIR 3.3 and higher supports multitasking on iOS by enabling certain background behaviors:
Opting out of background app execution
We thing that networking is the right behavior from our apps but this seems to be for a single taks execution and we need to execute the same process each 15 secs.
Any one have know how execute a http process ech x secs in background using the Networking behavior ?
Any one know if it's possible ?
voted... for what its worth.
Thank you Spedronimo.
I really hope it will be fixed soon or we'll all have to start learning another programming language...
So, after looking at the bug report - the status is now "closed/withdrawn" with the reasoning of "As Designed"?
So Adobe, you designed this problem and have no plans to fix it?
Could we get any type of answer on this?
How could such a big hole in the background processing of the software model be 'as designed'?
I would suggest this may be a big blocker to people using AIR as a platform to develop mobile apps. I know I won't be recommending it until this issue is resolved.
This really is a big bummer and I don't see how this is not a high priority issue, regardless of the implications it may have.
Saying this is "as designed" simply shows that the design has some major flaws.
Actually, I have tested in my app that, on Android at least ( didn't test on iOS ), execution in the background WILL work if renderMode = gpu, but NOT if renderMode = direct.
In other words, direct appears to be the only render mode which prevents background execution. Unfortunately, the direct render mode is necessary for the Stage3D API to work ( which I have also verified ).
Why this is a problem for me ( my use case ):
I am making a graphical alarm clock for Android/iOS, and recently implemented full hardware acceleration via Stage3D. On iOS, I am using local notifications to alert the user when alarm goes off and the app is minimized or closed. Said iOS local notification is scheduled ahead of time, if the alarm has been set, when the app is deactivated.
On Android, unfortunately, I cannot use the same strategy because local notifications on this platform cannot be scheduled ahead of time. Furthermore, with the app minimized and using direct render mode, I cannot trigger the local notification on the spot, while the app is minimized but running in the background. So I am stuck.
The right solution would be:
1) Allow background execution when the direct render mode is used ( preffered ).
2) Use an ANE for the AlarmManager on Android ( none available on the net, as of this writing ).
3) Use push notifications: very heavy handed ( requires server side scripting to schedule the notification ).
I am new to mobile develpment and creating a reminder application for Android & IOS using Flash Builder 4.6, Air 3.1. After surfing on net I got that we need to use ANE for the Alarm manager and Push notifications for the Alerts for Android platform. I am confused for this thing. Is there any simple way to create the application in Android.
Kindly Guide/Refer me for the way to develop background running application in Flash Builder 4.6.
Thanks in advance.
Some of the statements in this thread are no longer true, or need to be updated.
Here is a recap:
- As of AIR 3.9, background execution will work on iOS+Android with render mode set to 'direct' ( which implies that you are using Stage3D ).
- For background execution to work in iOS, you need:
- to set NativeApplication.nativeApplication.executeInBackground = true, in your as3 code somewhere ( note: strangely, background exec on iOS has worked for me in the past even by not doing that ).
- to add in the iPhone section of your app manifest ( *-app.xml ):
- UIApplicationExitsOnSuspend = false
- UIBackgroundModes = audio ( and/or location, or some other background mode ).
- a good excuse / reason : since battery-gate on the iPhone4, Apple has tightened its policies regarding background execution. For example: last time I tried, setting UIBackgroundModes=audio was only allowed if the app was intended to play a sound persistently in the background ( not occasionally, such as an alarm clock sound ).
- For local notifications, I recommend Distriqt's local notification ANE ( Android+iOS), since it's the ony one I know which uses the AlarmManager api on Android ( Koesler's Android Local notif doesn't last time I checked ). This means that on Android, the local notification can be scheduled for a later time ( same as iOS ), and will fire EVEN if the app is either minimized or has been closed properly ( meaning closed by the OS, or by the user via NativeApplication.nativeApplication.exit() -- note: force-stopping is the exception and cancels scheduled notifications on Android ). You can also have the local notification play a custom sound which is up to 30 secs long ( mp3s on Android / cafs on iOS). Sound will be audible on both platforms, even if the device is suspended. This is ideal for an alarm-clock, for example. The downside of local notifs is that they don't execute code, per se, however they can pass a data payload ( text ) back to the app, if it is running ( even if minimized ), which a handler can receive to do stuff.
Hey, thanks for updating this. I know its a year later now but it was cool that you posted updated info for folks chasing down these same answers. I just wish Apple wasnt so strict with background modes usage... Google will let you upload almost ANYTHING you can build, but iOS, not so much.