php检测手机是否开飞行模式,Android_android 如何判断当前是否为飞行模式,Android中如何判断系统当前是否 - phpStudy...

android 如何判断当前是否为飞行模式

Android中如何判断系统当前是否处于飞行模式中:

public static boolean IsAirModeOn(Context context) {

return (Settings.System.getInt(context.getContentResolver(),

Settings.System.AIRPLANE_MODE_ON, 0) == 1 ? true : false);

}

如何切换飞行模式

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);

}

如何注册和取消自动飞行时间

注册

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)

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硬件,我们可以通过设置该字符串的值,来控制这三个硬件是否在切换飞行模式是进行切换状态。相关阅读:

详解WordPress中给链接添加查询字符串的方法

轻松解决win7系统共享打印机脱机永久的方法

Java模拟新浪和腾讯自动登录并发送微博

Java的Hibernate框架数据库操作中锁的使用和查询类型

php实现的click captcha点击验证码类实例

SQL SERVER修改函数名容易引发的问题分析

MVC4制作网站教程第二章 部分用户功能实现代码

linux下图解挂载U盘全过程

hadoop常见错误以及处理方法详解

javascript在myeclipse中报错的解决方法

java计算百分比值的方法

mysql清除log-bin日志的方法

Win10怎么给照片文件设置备注?win10自带备注功能介绍

CSS下拉菜单简单制作教程

引用和引用提供了关于在phpstudy安装php扩展的指南。根据这些指南,你可以将php_yaf.dll文件放置在phpstudyPHP路径下,在php.ini文件手动添加extension=yaf的配置。具体来说,你可以将php_yaf.dll文件复制到D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext路径下,并在php.ini文件添加extension=yaf配置项。这样就可以在phpstudy的面板启用yaf扩展了。引用则提供了一个可能导致问题的原因,即项目使用的php版本与cmd的版本不兼容。你可以通过检查项目使用的php版本是否phpstudy的版本一致来确认这一点。如果版本不一致,可以在phpstudy切换php版本或者调整项目的php版本。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [阿里云服务下安装Composer时出现 错误:添加到用户路径:C:/phpStudy/Extensions/php/php7.3.4nts 安装无法...](https://blog.csdn.net/qq_42345116/article/details/122595160)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [php7.3.4可用yaf扩展下载phpstudy小皮面板php_yaf.dll(亲测100%可用)](https://download.csdn.net/download/lingyun820/16593737)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [执行php命令行出现 Failed loading D:\phpStudy\php\php7.3.4nts\ext\php_xdebug.dll](https://blog.csdn.net/weixin_42079053/article/details/105618234)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值