Claudia
Claudia

Reputation: 11

Looking for: Android Compass API

I'm programming an application for the Samsung Galaxy, using flash. I'd like to access the digital compass, but I can't with Actionscript. :(

So I was wondering: Is it possible to use an android api that checks the digital compass and writes the data to an XML-file? This API should run in the background while the flash-application is in front. …

Do you know any API that does this? Or some API that could be easily modified to work this way?

I don't know much about Java-programming or programming for Android, unfortunately.

Thanks for all your hints or ideas ... Claudia.

Upvotes: 1

Views: 3095

Answers (3)

Magic
Magic

Reputation: 11

Instead of doing a dirty workaround of saving the data to XML and then reading it in Flash, which will be slow btw, you can simply use Adobe Native Extensions. This is a mechanism that lest you write and use native Android code from Flash (Adobe AIR for Mobile).

Please see this link: http://www.adobe.com/devnet/air/native-extensions-for-air.html

And a tutorial here: http://www.adobe.com/devnet/air/articles/developing-native-extensions-air.html

Upvotes: 1

Rejinderi
Rejinderi

Reputation: 11844

look in this api demo http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.html

i think you can find something you need there..

do also look in http://developer.android.com/reference/android/hardware/SensorManager.html under SENSOR_ORIENTATION type

http://developer.android.com/reference/android/hardware/SensorManager.html#getOrientation(float[], float[])

SensorManager.getOrientation() can actually return the values you need!

Upvotes: 0

MusiGenesis
MusiGenesis

Reputation: 75296

You could write a "native" java application for Android that uses the SensorManager class to write values out to a file, driven by a Timer. However, this would pretty much defeat the purpose of doing the app in flash in the first place (unless you're doing this because you already know flash).

If this is an AIR app, there might be a hack that will let you access the Android APIs:

http://elromdesign.com/blog/2010/10/29/hacking-native-android-with-air-app-to-allow-air-access-unavailable-apis/

I only vaguely understand what they're doing and I haven't tried it myself.

Upvotes: 1

Related Questions