小米手机全面屏开关

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/HUandroid/article/details/85342297

小米手机全面屏开关问题

  • 判断是否开启全面屏
    开始以为只是简单的判断是否存在虚拟键就行了,结果发现无论你是否开启全面屏手势,结果都是 : 存在
    后来在小米开发论坛找到了这个问题:
Settings.Global.getInt(getContext().getContentResolver(), "force_fsg_nav_bar", 0) != 0;

上面这句代码是用来判断是否开启全面屏的核心代码,简单封装下:

public static boolean getIsOpenXiaomiQuanMianPing(Context context){
        boolean mIsXiaomiFull = false;
        String deviceName = android.os.Build.MANUFACTURER;//设备名称
        if (TextUtils.equals(deviceName, "Xiaomi")) {
            //6.0之后才有
            if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                mIsXiaomiFull = Settings.Global.getInt(context.getContentResolver(), "force_fsg_nav_bar", 0) != 0;
            }
        }
        return mIsXiaomiFull;
    }

猜你喜欢

转载自blog.csdn.net/HUandroid/article/details/85342297