如何检测是否启动主屏幕支持旋转 [英] How to Detect if Launcher Home Screen Supports Rotation

查看:159
本文介绍了如何检测是否启动主屏幕支持旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查设备是否启动主屏幕的支持方向,这可能吗?如果是的话,请帮助我。

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

例如,三星Galaxy Note 2不支持启动的方向,而银河兆丰一样。

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

推荐答案

您可以通过修改清单文件处理自己的屏幕旋转,只需添加的android:configChanges =方向你想要的活动。这意味着该系统本身不会处理再取向的变化。

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.

然后,为了落实行动过程中方向的变化做,添加以下code在活动

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
        }
    }

有关的设备,我想你可以尝试用例如型号过滤: android.os.Build.MODEL

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

这篇关于如何检测是否启动主屏幕支持旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆