寻找:Android 指南针 API
我正在使用 flash 为 Samsung Galaxy 编写应用程序。我想访问数字罗盘,但无法使用 Actionscript。 :(
所以我想知道:是否可以使用 android api 来检查数字罗盘并将数据写入 XML 文件?此 API 应该在 flash 应用程序运行时在后台运行前面...
你知道有什么API可以做到这一点吗? 或者一些可以轻松修改以这种方式工作的 API?
不幸的是,我对 Java 编程或 Android 编程了解不多。
感谢您的所有提示或想法... 克劳迪娅.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以为Android编写一个使用SensorManager 类,用于将值写入文件,由计时器驱动。然而,这基本上就违背了在 Flash 中开发应用程序的初衷(除非您这样做是因为您已经了解 Flash)。
如果这是一个 AIR 应用程序,则可能有一个 hack 可以让您访问 Android API:
http://elromdesign.com/blog/2010/10/29/hacking-native-android-with-air-app -to-allow-air-access-unavailable-apis/
我只是模糊地理解他们在做什么,我自己还没有尝试过。
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.
您可以简单地使用 Adobe Native Extensions,而不是采用将数据保存到 XML,然后在 Flash 中读取数据的肮脏解决方法(顺便说一句,这会很慢)。这是一种防止您编写和使用 Flash (Adobe AIR for Mobile) 的本机 Android 代码的机制。
请参阅此链接:
http://www.adobe.com/devnet/air/native -extensions-for-air.html
这里有一个教程:
http://www.adobe.com/devnet/air /articles/developing-native-extensions-air.html
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
看看这个api演示 http: //developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.html
我想你可以在那里找到你需要的东西..
也看看
http://developer.android.com/reference/android/hardware/SensorManager.html
在 SENSOR_ORIENTATION 类型下
http://developer.android.com/reference/android/hardware/SensorManager.html#getOrientation(float[], float[])
SensorManager.getOrientation() 实际上可以返回您需要的值!
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!