android 判断当前是否是飞行模式和侦听airplane mode change
在AirplaneModeEnabler中 提供了isAirplaneModeOn方法来判断当前是否是Airplane mode:public static boolean isAirplaneModeOn(Context context) {
return Settings.System.getInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) != 0;
} www.zzzyk.com
侦听是否airplane mode 发生改变,可以用注册intentFilter 来侦听。
BroadcastReceiver mReceiver = new AirplaneModeBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
registerReceiver(mReceiver, intentFilter);
private class AirplaneModeBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
// add your code here ………
}
}
}
补充:移动开发 , Android ,