1

通過配置和方向更改幾個帖子和線程,但仍然不清除。如何通過任何聽衆跟蹤反向(reverseLandscape和reversePortrait)?

由於onConfigurationChanged被稱爲只有當orientation變化從landscapeportrait或任portraitlandscape(如名字所暗示的),但有什麼辦法可以聽reverseLandscapereversePortrait方向改變通過任何還挺任何API級大腕。

還是有可能聽rotation變化像onConfigurationChanged

任何有點幫助將高度讚賞!

+0

http://stackoverflow.com/a/2799001/1008278 – VenomVendor 2013-03-16 11:15:32

+0

我需要聽衆跟蹤每當設備從風景旋轉到reverseLandscape或肖像reversePortrait。 – 2013-03-16 11:17:40

回答

1

可以使用加速度計和磁場傳感器來計算裝置旋轉,然後調用

getWindowManager().getDefaultDisplay().getRotation(); 

當旋轉是在一定的值。計算旋轉的方式是在我的回答How to measure the tilt of the phone in XY plane using accelerometer in Android

+0

感謝您的答覆,但我不想去那麼多的計算知道只是方向,因爲我認爲他們將任何回電話聽衆,這將給設備旋轉時的旋轉或方向,運氣不佳我dint找到答案了! ! +1 – 2013-03-23 17:48:51

+0

實際上,您不需要使用傳感器來獲得旋轉。只需註冊OrientationEventListener。它會給你旋轉的角度。 – 2013-03-23 17:55:37

+0

我想要的是在我的問題中已經提到,reverseLandscape和reversePortrait! – 2013-03-23 17:58:36

1

您可以檢索該4個方向是目前積極通過調用

getWindowManager().getDefaultDisplay().getRotation(); 

知道何時調用它可能會非常棘手,因爲如果你從portrait直奔reversePortrait對系統不會通知你實例。實現這一目標的唯一方法是使用設備的傳感器。這article from the Android Developers Blog應該可以幫到你。

+0

我正在尋找相同的技巧! – 2013-03-16 11:42:56