无法在Android Oreo中设置屏幕方向

时间:2018-10-09 04:58:22

标签: java android

现在我正在开发一个android应用程序,我想将屏幕方向设置为横向模式,在所有设备上都可以正常工作,但是问题是当我尝试在android oreo中运行该应用程序时,该应用程序崩溃了。拜托,有人帮我吗?

我在这里添加了日志,

FATAL EXCEPTION: main
                                                               Process: com.wowword.wowword, PID: 4863
                                                               java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wowword.wowword/com.wowword.wowword.activity.MainActivity}: java.lang.IllegalStateException: Only fullscreen activities can request orientation
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                                   at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                   at android.os.Looper.loop(Looper.java:164)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                                Caused by: java.lang.IllegalStateException: Only fullscreen activities can request orientation
                                                                   at android.os.Parcel.readException(Parcel.java:1951)
                                                                   at android.os.Parcel.readException(Parcel.java:1889)
                                                                   at android.app.IActivityManager$Stub$Proxy.setRequestedOrientation(IActivityManager.java:5675)
                                                                   at android.app.Activity.setRequestedOrientation(Activity.java:5739)
                                                                   at com.wowword.wowword.activity.MainActivity.onCreate(MainActivity.java:66)
                                                                   at android.app.Activity.performCreate(Activity.java:6975)
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
                                                                   at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
                                                                   at android.os.Handler.dispatchMessage(Handler.java:105) 
                                                                   at android.os.Looper.loop(Looper.java:164) 
                                                                   at android.app.ActivityThread.main(ActivityThread.java:6541) 
                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

我这样设置方向

 requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    overridePendingTransition(R.anim.do_not_move, R.anim.do_not_move);
    setContentView(R.layout.activity_main);
    //set screen orientation
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

这是我的清单文件,

 <application
    android:name=".WowWord"
    android:allowBackup="true"
    android:hardwareAccelerated="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppThemeNoActionBar">
    <activity
        android:name="com.wowword.wowword.activity.SplashScreenActivity"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.wowword.wowword.activity.MainActivity"
        android:launchMode="singleInstance"
        android:theme="@style/AppThemeNoActionBar"/>

    <activity
        android:name="com.wowword.wowword.activity.HelpVideoActivity"
        android:theme="@style/AppThemeNoActionBar" />
    <activity
        android:name="com.wowword.wowword.activity.PlayScreenActivity"
        android:theme="@style/AppThemeNoActionBar" />
    <activity
        android:name="com.wowword.wowword.activity.MenuScreenActivity"
        android:theme="@style/AppThemeNoActionBar" />
    <activity
        android:name="com.wowword.wowword.activity.VideoViewActivity"
        android:theme="@style/AppThemeNoActionBar" />
    <activity
        android:name="com.wowword.wowword.activity.ApplicationClosingActivity"
        android:theme="@style/AppThemeNoActionBar" />

    <service
        android:name="com.amazonaws.mobileconnectors.s3.transferutility.TransferService"
        android:enabled="true" />
</application>

0 个答案:

没有答案