在Android上禁用肖像模式

在Android上禁用肖像模式,android,crashlytics,landscape-portrait,portrait,Android,Crashlytics,Landscape Portrait,Portrait,我希望我的应用程序只在横向上运行,所以我在清单中的每个活动中都添加了android:screenOrientation=landscape <activity android:name=".MainActivity" android:screenOrientation="landscape"> <intent-filter> <action android:name="android.intent.ac

我希望我的应用程序只在横向上运行,所以我在清单中的每个活动中都添加了android:screenOrientation=landscape

    <activity android:name=".MainActivity"
        android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
但令人惊讶的是,Crashlytics中出现了如此多的崩溃,数据显示,崩溃发生在设备处于纵向模式时,为什么它处于按比例模式

飞机坠毁时说

Caused by android.content.res.Resources$NotFoundException
Resource ID #0x7f0a001e
android.content.res.Resources.getValue (Resources.java:2327)
android.content.res.Resources.loadXmlResourceParser (Resources.java:3692)
android.content.res.Resources.getLayout (Resources.java:2143)
android.view.LayoutInflater.inflate (LayoutInflater.java:396)
android.view.LayoutInflater.inflate (LayoutInflater.java:354)
android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:287)
android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:139)
com.xx.xxx.Activity.onCreate (Activity.java:42)
android.app.Activity.performCreate (Activity.java:5447)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1094)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2393)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2493)
android.app.ActivityThread.handleRelaunchActivity (ActivityThread.java:4014)
android.app.ActivityThread.access$900 (ActivityThread.java:166)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1289)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:136)
android.app.ActivityThread.main (ActivityThread.java:5584)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1268)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1084)
dalvik.system.NativeStart.main (NativeStart.java)
这是我的onCreate方法 @凌驾

   protected void onCreate(Bundle savedInstanceState) {
        setTheme(((AppTheme)getApplicationContext()).getCurrentTheme());
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_layout);
        ButterKnife.bind(this);
        presenter = new Presenter(this);
        setupPages();
        enterImmersiveMode();
    }

我想知道Crashlytics上是如何记录当设备处于纵向模式时会发生崩溃的。所以我猜当它处于纵向模式时,它无法获得布局,因为布局栏中的所有布局都不在布局文件夹中。

我不想鼓励懒惰。答案是这样的

不过,请下次使用谷歌。这是一些你可以很容易找到的基本信息

将android:screenOrientation=横向添加到清单中的活动

    <activity android:name=".MainActivity"
        android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

您还可以使用setRequestedOrientationandroid.content.pm.ActivityInfo.SCREEN\u orientation\u景观在运行时更改方向;但是您应该在setContentView之前调用onCreate方法,该方法可能会重复发布整个crashpost。这些行中哪一行是第42行?@droidv setContentViewR.layout.activity\u layout;这不是懒惰,这是我在做的。但是在发布我的应用程序后,我打开了Crashlytics,当应用程序运行时会发生很多崩溃检查更新的问题,可能我之前没有解释清楚不..你以前没有解释过这些。。。喜欢我错了,也许我不知道该怎么解释,你有什么想法吗?把你的整个crashit设置成横向,和我一起正确工作,但是我遇到了很多崩溃。我不知道为什么!真的很奇怪。如果在AndroidManifest.xml中设置,则即使用户旋转其设备,也不应更改