如何检测飞行模式尤其是在果冻梁木呢? [英] How to detect airplane mode especially in jelly beam?

查看:198
本文介绍了如何检测飞行模式尤其是在果冻梁木呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该娄code检测飞行模式不果冻梁版本的作品。

The bellow code to detect airplane mode not works in jelly beam version.

    // Check for Airplane Mode
    boolean isEnabled = Settings.System.getInt(getContentResolver(),Settings.System.AIRPLANE_MODE_ON,0) == 1;

if (isEnabled) {
// toggle airplane mode
Settings.System.putInt(getContentResolver(),
Settings.System.AIRPLANE_MODE_ON,isEnabled ? 0 : 1);
// Post an intent to reload
Intent intent = new Intent(                 Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", !isEnabled);
sendBroadcast(intent);
}

请分享您的建议对我的怀疑。在此先感谢

Please share your suggestion for my doubt. Thanks in advance

推荐答案

这是code段是低于JB

This Is Code Snippet is for below JB

    /**
* Gets the state of Airplane Mode.
* 
* @param context
* @return true if enabled.
*/
private static boolean isAirplaneModeOn(Context context) {

   return Settings.System.getInt(context.getContentResolver(),
           Settings.System.AIRPLANE_MODE_ON, 0) != 0;

}

果冻豆4.2 ,这个设置已经转移到 Settings.Global

In Jelly Bean 4.2, this setting has moved to Settings.Global

这篇关于如何检测飞行模式尤其是在果冻梁木呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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