android 判断 飞行模式,如何在Android上检测飞行模式?
叮當(dāng)貓咪
通過擴(kuò)展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;? ? }? ? ? ?}
總結(jié)
以上是生活随笔為你收集整理的android 判断 飞行模式,如何在Android上检测飞行模式?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android studio faile
- 下一篇: android wifi定位服务,如何在