开发者

BlackBerry magnetometer direction - which direction?

开发者 https://www.devze.com 2023-04-12 00:06 出处:网络
I am currently trying to use the new BlackBerry Magnetometer API but am unfortunately coming 开发者_JAVA百科up against various issues. I have got the magnetometer working but I can\'t get reliable res

I am currently trying to use the new BlackBerry Magnetometer API but am unfortunately coming 开发者_JAVA百科up against various issues. I have got the magnetometer working but I can't get reliable results from it.

On the iPhone compass, if you hold the phone with its top facing the sky, or if you hold the phone with its screen facing the sky, you get the same readings on the compass. However, on BlackBerry there are various directions given by the MagnetometerData which confuse me.

As far as I can tell getDirectionTop returns the angle when the phone is flat on its back and getDirectionBack returns the angle when the phone is being held with its top to the sky.

Is there a way to get the direction based on the phones orientation? For example, automatically detect if the phone is flat or upright and get the required direction based on that?


Sure, via the accelerometer API.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号