检查Android手机中的移动数据是否打开

问题描述

我在以下链接上引用了代码ref

在Build.VERSION_CODES.JELLY_BEAN_MR1之前和之后会有什么不同。

在哪里可以找到提到的与此不同的文档?

谢谢!

boolean mobileYN = false;

    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    if (tm.getSimstate() == TelephonyManager.SIM_STATE_READY) {
        if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1)
        {
            mobileYN = Settings.Global.getInt(context.getContentResolver(),"mobile_data",1) == 1;
        }
        else{
            mobileYN = Settings.Secure.getInt(context.getContentResolver(),1) == 1;
        }
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)