Why has `android:screenOrientation="behind"` no effect in android 4.1.2? Why has `android:screenOrientation="behind"` no effect in android 4.1.2? android android

Why has `android:screenOrientation="behind"` no effect in android 4.1.2?


If you are facing problem changing orientation using manifest you change the orientation in java. Here is complete code for manifest and activities.

Manifest.xml

<uses-sdk    android:minSdkVersion="8"    android:targetSdkVersion="16" /><application    android:allowBackup="true"    android:icon="@drawable/ic_launcher"    android:label="@string/app_name"    android:theme="@style/AppTheme" >    <activity        android:name="com.my.example.testbehindorientation.MainActivity"        android:label="@string/app_name" >        <intent-filter>            <action android:name="android.intent.action.MAIN" />            <category android:name="android.intent.category.LAUNCHER" />        </intent-filter>    </activity>    <activity        android:name="com.my.example.testbehindorientation.SecondActivity"        android:configChanges="screenSize|orientation"        android:label="@string/title_activity_second" >    </activity></application>

Second activity in landscape

@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_second);                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//Change according to need this is for landscape    logOrientation("onCreate");}@Overrideprotected void onDestroy() {    super.onDestroy();    logOrientation("onDestroy");}@Overrideprotected void onResume() {    super.onResume();    logOrientation("onResume");}private void logOrientation(String prefix) {        int requestedOrientation = this.getRequestedOrientation();        WindowManager lWindowManager =  (WindowManager) getSystemService(WINDOW_SERVICE);        Configuration cfg = getResources().getConfiguration();        int lRotation = lWindowManager.getDefaultDisplay().getRotation();           int orientation = cfg.orientation;        Log.i(LOG_TAG, prefix + ", requestedOrientation is " + requestedOrientation + ", rotation is " + lRotation + ", orientation is " + orientation);}

Add the following code in onCreate() method of MainActivity

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//Change according to need this is for landscape


android:targetSdkVersion="16"

Remove this statement in your manifest file, because SDKVersion=16 is only available for v4.0.