开发者

How to block the screen orientation and still get orientation changes notifications

I want to block my开发者_高级运维 application orientation to portrait, but still receive orientation changes events. So I've tried to add the android:screenOrientation="portrait" attribute for blocking the orientation and the android:configChanges="keyboardHidden|orientation" attribute for receiving the orientation changes events in the ovverriden method onConfigurationChanged. Still the method doesn't get called. Is there a way to achieve this?


By forcing the orientation of your activity to portrait mode, you're not able to receive orientation changes.


Check Manifest.xml file. It should be like as below:

    <activity android:name="YourActivity1"
        android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan"
        android:configChanges="orientation|keyboardHidden"></activity>
    <activity android:name="YourActivity2"
        android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan"
        android:configChanges="orientation|keyboardHidden"></activity>


are you sure you write this for main activity like < activity android:screenOrientation="portrait"...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜