麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統(tǒng) > Android > 正文

android 如何判斷當(dāng)前是否為飛行模式

2020-04-11 12:41:30
字體:
供稿:網(wǎng)友
Android中如何判斷系統(tǒng)當(dāng)前是否處于飛行模式中:
復(fù)制代碼 代碼如下:

public static boolean IsAirModeOn(Context context) {
return (Settings.System.getInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) == 1 ? true : false);
}

如何切換飛行模式
復(fù)制代碼 代碼如下:

public static void setAirplaneMode(Context context, boolean enabling) {
Settings.System.putInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, enabling ? 1 : 0);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", enabling);
context.sendBroadcast(intent);
}

如何注冊和取消自動飛行時間
注冊
復(fù)制代碼 代碼如下:

AlarmManager am = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(AIR_ALERT_ACTION);
Parcel out = Parcel.obtain();
air.writeToParcel(out, 0);
out.setDataPosition(0);
intent.putExtra(AIR_RAW_DATA, out.marshall());
PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
am.set(AlarmManager.RTC_WAKEUP, atTimeInMillis, sender);取消
AlarmManager am = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
endingIntent sender = PendingIntent.getBroadcast(context, 0,
new Intent(action), PendingIntent.FLAG_CANCEL_CURRENT);
am.cancel(sender);

如何控制切換飛行模式的硬件(cell,Bluetooth,wifi)
復(fù)制代碼 代碼如下:

Settings.System.putString(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_RADIOS, air_mode_radios);air_mode_radios為一個這樣的字符串,看android源碼中android/provider/Settings.java

/***
* Whether Airplane Mode is on.
*/
public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
/***
* Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
*/
public static final String RADIO_BLUETOOTH = "bluetooth";
/***
* Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
*/
public static final String RADIO_WIFI = "wifi";
/***
* Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
*/
public static final String RADIO_CELL = "cell";
/***
* A comma separated list of radios that need to be disabled when airplane mode
* is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
* included in the comma separated list.
*/
public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";
/***
* A comma separated list of radios that should to be disabled when airplane mode
* is on, but can be manually reenabled by the user. For example, if RADIO_WIFI is
* added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
* will be turned off when entering airplane mode, but the user will be able to reenable
* Wifi in the Settings app.
*
* {@hide}
*/
public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";

如果air_mode_radios=“cell,bluetooth,wifi”,這就便是切換飛行模式是切換字符串中的這cell,bluetooth,wifi硬件,我們可以通過設(shè)置該字符串的值,來控制這三個硬件是否在切換飛行模式是進(jìn)行切換狀態(tài)。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 毛片视频大全 | 九九视屏 | 免费观看又色又爽又黄的崩锅 | 成人性生活视频在线观看 | 超碰97人人艹 | 久久成人免费网 | 欧美日本在线视频 | 国产精品久久久久一区二区 | 黄色片免费看网站 | 奶子吧naiziba.cc免费午夜片在线观看 | 国产亚洲美女精品久久久2020 | 韩国草草影院 | 深夜影院a | 欧美h版在线观看 | 免费的毛片| 春光影院理论片 | 性 毛片| 手机国产乱子伦精品视频 | 国产99久久久国产精品 | 欧美18videos性处按摩 | 97人人草| 一级黄色影院 | 日本a在线观看 | 久久国精品 | 国产一区二区免费在线观看视频 | 一道本不卡一区 | 911色_911色sss主站色播 | 欧美性猛交一区二区三区精品 | 成人免费区 | 欧美一级精品 | 国产精品视频六区 | 在线播放一区二区三区 | 日本黄色大片免费观看 | 久久久一区二区三区四区 | 国产正在播放 | 久草最新网址 | gogo全球大胆高清人露出91 | 国产午夜精品一区二区三区免费 | 欧洲a级片| 伦一区二区三区中文字幕v亚洲 | 国产无区一区二区三麻豆 |