由网友(脏了别捡)分享简介:我有code。在我的应用程序检测如果Wi-Fi是否已连接。这code触发一个RuntimeException如果启用飞行模式。我想反正显示,当在此模式下单独的错误消息。我怎样才能可靠地检测如果一个Android设备处于飞行模式?解决方案 / ***获取的飞行模式状态。** @参数方面* @返回true,如...
我有code。在我的应用程序检测如果Wi-Fi是否已连接。这code触发一个RuntimeException如果启用飞行模式。我想反正显示,当在此模式下单独的错误消息。我怎样才能可靠地检测如果一个Android设备处于飞行模式?
解决方案 / **
*获取的飞行模式状态。
*
* @参数方面
* @返回true,如果启用。
* /
私有静态布尔isAirplaneModeOn(上下文的背景下){
返回Settings.System.getInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON,0)!= 0;
}
I have code in my application that detects if Wi-Fi is actively connected. That code triggers a RuntimeException if airplane mode is enabled. I would like to display a separate error message when in this mode anyway. How can I reliably detect if an Android device is in airplane mode?
解决方案/**
* 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;
}
相关推荐
最新文章