Accessing Compass Data With AIR 3

I just finished writing a simple compass application for AIR 3 that uses an ANE (AIR Native Extension) to get orientation data from the Android operating system. All the code (AIR application, Java native extension, and "glue" library code) is available on Github if you want to see how it works.

15 Responses to Accessing Compass Data With AIR 3

  1. rob mckeown says:

    Is it just me or was the label at the top of the app not showing the correct value? When the red arrow was pointing south west the label said “SE”.

    Aside from that this is pretty awesome. The ability to tap into other features of the device/os is going to be huge!

  2. Christian Cantrell says:

    @rob: That’s actually the result of my questionable design. I tried to make it behave like an actual compass with static directions below the needle. It is confusing, though, since the direction indicator on the top changes. Honestly, I have no idea how to design a good compass. 🙂

  3. Pingback: Slides, Links, and Questions From my MAX 2011 Presentation « Christian Cantrell

  4. Great stuff! Do you maybe know if someone already created an iOS counterpart of your Android native extension? That would be ideal for apps targeted at both platforms!

  5. Hi,

    really great stuff and I like to use it, but could you provide the .ane file? Maybe I am kust to blind to see the easy way on building from your github code, but it would be much easier if you could provide it.

    thx alex

  6. Michael Baisuck says:

    I’m using Flash CS5.5 (as opposed to Flex) and I can’t get this compass example to work. 🙁
    No matter what I do to this line:
    this.exContext = ExtensionContext.createExtensionContext(“com.christiancantrell.compass”,”compass”);

    I get the following error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.

    Can you help me out here???
    Thanks.
    Mike

  7. Michael Baisuck says:

    I’m very confused. Does the Java code need to be compiled into a JAR file to work? I guess it must. Can you provide the JAR file if it is required? (I don’t have a way to compile Java code at present.)
    Thanks.

  8. Michael Baisuck says:

    I’m starting to think that Adobe is abandoning Flash. Can Native Extensions even be implemented outside of Flex and Flash Builder? If so, I could really use some assistance…

  9. Michael Baisuck says:

    Can someone PLEASE give me some pointers on how to compile the Java extensions? Thanks.

  10. Pingback: Porting an AIR Application to HTML « Christian Cantrell

  11. I’ve blogged about getting Native Extensions compiled using Ant and Flashdevelop here – http://blog.wrench.com.au/2011/11/02/native-extensions-for-android-with-air-3-and-flashdevelop/

    The sourcecode (including the compiled swc and .ane file that people have been requesting above) can be found on the post as well 😉

  12. Julio says:

    Hello, I don’t know how to compile the java project.
    I’ve an error in the CompassANEActivity class at line 13 : R can not be solved as a variable

    Help please

    Thanks

  13. Lorenzo says:

    I’m using the packaged ANE from Jason Langdon. Thanks Christian for the App and Jason for building the ANE.

    One issue I’m finding on Android 3.2 is that it takes about a minute or so before the first azimuth reading starts coming through. (in other words onActivate handler is not called for at least a minute) Is that normal ?

    I’m also fetching GPS values and they come through in seconds.

    Thanks!

  14. Ken says:

    How can I access the magnetic compass output using Flash in the Blackberry PlayBook? If you could reply to me by email, that would be wonderful.