Search code examples
javaandroidandroid-orientation

Issue in changing orientation in android


Just making a test application that should display a log message on changing orientation, but when i change orientation using ctrl + f11, there is nothing shown in the logcat. what is the issue in the coding

A Part From Manifest

<activity
            android:name="com.example.orientationtest.MainActivity"
            android:label="@string/app_name"
            android:configChanges="orientation|screenSize" >

A part from Java

package com.example.orientationtest;

import android.os.Bundle;
import android.app.Activity;
import android.content.res.Configuration;
import android.util.Log;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        // TODO Auto-generated method stub
        super.onConfigurationChanged(newConfig);

        Log.d("error", " orientation changes");
    }

}

Solution

  • try this if target api 13 and above

      android:configChanges="orientation|keyboardHidden|screenLayout|screenSize" 
    

    or

       android:configChanges="orientation|keyboardHidden|screenLayout" 
    

    for lower than 13 ..... this will help you... :)