so want app lock onto natural orientation of device. basically, want force rotation 0 degrees. there's getrotation()
method here:
http://developer.android.com/reference/android/view/display.html
however, there no setrotation(int rotation) accept 1 of surface.rotation_x
parameters found here: http://developer.android.com/reference/android/view/surface.html
so, there way single line of code work? or have done code?
the thing can think of manual solution following, have concerns it.
i can use display.getrotation()
. i'll check if it's 0 or 180 degrees, after i'll display height , width, , see 1 longer other. if appears i'm in landscape mode, i'll know device's natural orientation landscape set landscape. if rotation 270 or 90, know natural orientation portrait, , set portrait.
however, concern such works. let's user rotating screen piece of code executing, if device changes orientation in between time use getrotation()
method, , check width against height if statements , not, think throw off. happens if put in oncreate()
or onresume()
? possible things can out of wack?
is possible oncreate()
or onresume()
interrupted screen re-orientation due user turn device around? other issue if flip device 180 degrees, activity never destroyed, think behavior of situation whether it's 90 degree turn, or 180 degree turn.
you can "set" screen orientation in manifest. see here: http://developer.android.com/guide/topics/manifest/activity-element.html#screen
<activity android:name=".activity" android:screenorientation="portrait" android:theme="@style/theme.d1" android:label="@string/title_activity"/>
the value you're looking is; "user" user's current preferred orientation. however, test on several test cases sure. hth!
Comments
Post a Comment