简体   繁体   English

如何检测启动器主屏幕是否支持旋转

[英]How to Detect if Launcher Home Screen Supports Rotation

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. 例如,三星Galaxy Note 2不支持启动器方向,而Galaxy Mega支持。

You can handle yourself the screen rotations by modifying the Manifest file, just add android:configChanges="orientation" for the activities you want. 您可以通过修改清单文件来处理屏幕旋转,只需为所需的活动添加android:configChanges="orientation" 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 : 然后,为了实施在方向更改期间要执行的操作,请在您的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 . 对于设备,我认为您可以尝试使用以下模型进行过滤: android.os.Build.MODEL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM