How to Detect if Launcher Home Screen Supports Rotation

℡╲_俬逩灬. 提交于 2019-12-11 02:09:53

问题


I need to check if the device launcher home screen support orientation, is that possible? if so please help me out.

for instance, Samsung Galaxy Note 2 does not support launcher orientation while Galaxy Mega does.


回答1:


You can handle yourself the screen rotations by modifying the Manifest file, just add android:configChanges="orientation" for the activities you want. It means that the system will not handle by itself the orientation changes anymore.

Then in order to implement the actions to do during the orientation changes, add the following code in your Activity:

public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            //TODO
        } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            //TODO
        }
    }

For the devices, I think you can try filtering with the models for example: android.os.Build.MODEL.



来源:https://stackoverflow.com/questions/18941524/how-to-detect-if-launcher-home-screen-supports-rotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!