androidandroid-manifestlandscape

How to specify landscape in Android < 9 and sensorLanscape in Android >= 9 in manifest?


I have an app that needs landscape orientation.

So I like to use android:screenOrientation="sensorLandscape" in the manifest.

But for Android < 9 that is not supported, there I need to use android:screenOrientation="landscape"

Just putting both in the manifest gives an error.

Is there a way to solve this in the manifest or do I really need to handle this programmatically in each activity onCreate using android.os.Build.VERSION.SDK_INT ?


Solution

  • You need to do it programmatically. Here's an example:

    https://groups.google.com/forum/?fromgroups=#!topic/android-developers/0Ej-K4BpaEo