开发者

Application in fixed landscape. How to detect phone orientation

开发者 https://www.devze.com 2023-03-12 18:31 出处:网络
I\'m building android app that is only in landscape mode. How can i detect the phone orientation as fast as开发者_如何学编程 possible? I have tried with

I'm building android app that is only in landscape mode. How can i detect the phone orientation as fast as开发者_如何学编程 possible? I have tried with

`Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();

display.getOrientation();`

and also with the SensorEventListener, but I can't get any values for X,Y or Z? How can I do this? any solution? I was using this example for sensor. link for the sensor event listener


To keep an activity only in portrait mode add this in the manifest xml tag

android:screenOrientation="portrait"

0

精彩评论

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