To lock my orientation to portrait, I use:
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
I'm unsure what flag tells the activity to go back to relying on the device orientation. I imagine it is one of these:
SCREEN_ORIENTATION_FULL_SENSOR
SCREEN_ORIENTATION_SENSOR
SCREEN_ORIENTATION_UNSPECIFIED
SCREEN_ORIENTATION_USER
On another note, why isn't the android documentation open source? The documentation is completely lacking. Very few of the functions and flags have useful descriptions.
根据http://developer.android.com/reference/android/R.attr.html#screenOrientation (如果你SCREEN_ORIENTATION_SENSOR
SCREEN_ORIENTATION_FULL_SENSOR
文档,screenOrientation就是那些值链接到的那些), SCREEN_ORIENTATION_SENSOR
或SCREEN_ORIENTATION_FULL_SENSOR
将会这样做,具体取决于多少您想要的灵活性 - 但是,我怀疑您真正想要的是返回默认设置,即SCREEN_ORIENTATION_UNSPECIFIED
以便它返回到系统默认设置,包括任何用户设置。
An easy fix for this that worked for me is to add a line to AndroidManifest.xml like so:
Add android:screenOrientation="portrait"> in the application section.
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".App"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
如果此活动的应用程序
manifest entry
的“android:immersive"
属性设置为“true
”,则ActivityInfo.flags
成员始终设置其FLAG_IMMERSIVE位,即使沉浸模式在运行时使用“setImmersive()
更改”setImmersive()
“ 方法。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.