android 判断 飞行模式,如何在Android上检测飞行模式?

叮当猫咪
通过扩展Alex的答案以包括SDK版本检查,我们可以:/** * Gets the state of Airplane Mode. * * @param context * @return true if enabled. */@SuppressWarnings("deprecation")@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)public static boolean isAirplaneModeOn(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; } else { return Settings.Global.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0; } }
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
