Zeburek Zeburek -4 years ago 131
Android Question

Listen on orientation changes

Trying to listen to orientation change in my android program, but nothing works.
My solutions:

to my activity in AndroidManifest
and added this in my Activity class:

public void onConfigurationChanged(Configuration newConfig) {
Log.d(TAG_ZT, "Config changed.");


But it doesn't work.

Next my solution was adding:

OrientationEventListener orientationEventListener = new OrientationEventListener(MainActivity.this.getApplicationContext()) {
public void onOrientationChanged(int orientation) {
Log.d(TAG_ZT, "onOrientationChanged: "+orientation);

But also No work.
What I'm doing wrong?

Answer Source

You must be using PPI level 13 or higher. In this case use configChanges="orientation|screenSize" otherwise onConfigurationChanged will not be called.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download