Paruyr
Paruyr

Reputation: 47

How handle Android Device 180 degree rotation (reverseLandscape)? - onConfigurationChanged is not called

When rotating phone 180 degree onConfigurationChanged Callback is not called, only works when changing rotation from portrait to landscape and vice verse, however rotating 180 degree when on landscape view is rotated however onConfigurationChanged callback is not called. How to handle 180 rotating.

my Manifest

<activity
            android:name="com.myApp.Activity"
            android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>

my Activity

@Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Toast.makeText(this, "rotated", Toast.LENGTH_SHORT).show();
    }

Upvotes: 1

Views: 1208

Answers (2)

UgurBH
UgurBH

Reputation: 1

Kind of late answer but it may help in the future.

Call setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR) in your main activity's onCreate method.

Below works for me.

MainActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);

Upvotes: 0

laalto
laalto

Reputation: 152817

The default screenOrientation mode behavior is vendor and device specific. For phones, it's typical that only -90°, 0° and 90° are supported.

To support all orientations, add android:screenOrientation="fullSensor" to your activity's manifest entry.

Docs: https://developer.android.com/guide/topics/manifest/activity-element#screen

Upvotes: 1

Related Questions