1

Is it possible to receive accelerometer data in background with AIR? (similar to Nike+ on iOS)

I read that it's possible with Objective-C if we use "Core Motion Framework" and "UIBackgroundModes=location". What about Air?

Thank you

Bartek
  • 1,059
  • 6
  • 18
fperreault
  • 13
  • 3

1 Answers1

1

From what I've seen it appears my application goes completely idle when you navigate away to another application/screen. From what I'm reading here it doesn't appear to be possible to keep getting info about the accelerometer.

http://blogs.adobe.com/airodynamics/2012/05/04/air-ios-background-behavior/

Hmm k did a bit more digging around to verify if you could do this with a native extension assuming the built in Accelerometer class doesn't provide the necessary functionality. Apparently the Core Motion framework way of accessing the Accelerometer does allow it to continue to be "polled" in the background: How Nike+ GPS on iPhone receives accelerometer updates in the background?

Since I own exactly 0 iOS devices I can't really test this one for you but would be interested to hear how it works out, best of luck.

Community
  • 1
  • 1
shaunhusain
  • 19,630
  • 4
  • 38
  • 51
  • Oh so that's what the OP meant by "background". – inhan Jan 08 '13 at 22:01
  • @inhan I believe so, I'm building a painting app in AIR, going pretty well but from debugging with Scout it appears as soon as I navigate away my app goes idle (which IMO is a good thing, but I can see how it could be a problem if your app isn't all UI focused). It seems this is a limitation of iOS though not AS3 or AIR themselves so even a native extension wouldn't help (from how I'm reading it) – shaunhusain Jan 08 '13 at 22:03
  • 2
    @shaunhusain It works fine. I can get accelerometer data in background only if I use Air Native Extension and Core Motion Framework. This the only way. The UIBackgroudMode "location" need to be set in the application descriptor and AS need to have NativeApplication.nativeApplication.executeInBackground = true. With a little Objective-C, the application can get the accelerometer in background/sleepMode for many hours without any crash. – fperreault Apr 03 '13 at 03:31