New to Android development here.I'm currently making an app in which when the Orientation changes . I want the message in my LogCat .For this I have made onConfigurationChanged(Configuration newConfig) method in the MainActivity, but it is not called when running the program.
Basically, I want to cease my Activity from restarting upon a device orientation change. To do this, I have modified the activity in the manifest file: I used
android:configChanges="orientation|screenSize"
android:minSdkVersion="8"
android:targetSdkVersion="17"
ON LogCat I'm getting text as follows:
Emulator without GPU emulation detected.
The application may be doing too much work on its main thread.
I already found a solution through Google in which above targetSdkVersion "17" we use--
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|layoutDirection"
It is also not working.
Can anyone help me out?
This is my MainActivity:
package com.example.orientation;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Configuration c = getResources().getConfiguration();
Log.e("Config",""+c);
if (c.orientation == Configuration.ORIENTATION_PORTRAIT)
{
// portrait
Log.e("On Config Change","portrait");
}
else if (c.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
// landscape
Log.e("On Config Change","LANDSCAPE");
}
}
}
However, the Program is running when the orientation changes, but the onConfigurationChanged() method is not being called.
Does anyone know why this may be happening?