So i have simple code, i just want to change layout when i screen orientation is changed.
package com.example.asdasd;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onConfigurationChange(Configuration newConfig){
super.onConfigurationChanged(newConfig);
setContentView(R.layout.asdasd);
System.out.println("orientation---"+getResources().getConfiguration().orientation);
}
}
my manifest is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.asdasd"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.asdasd.MainActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
So when i try this out on emulator and use ctrl+f12 or 9and 7 on num, screen flips but nothing happends and my layout stays the same, it wont work. Its like onConfigurationChange is never called and System.out.println is never reached.