[英]How can I change the behavior of Android's airplane mode so that it will not turn off the cellular radio?
[英]turning airplane mode on and off and how to turn on mobile data in android
我使用以下代码在android上启用飞行模式:
Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1);
newIntent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
newIntent.putExtra("state", true);
context.sendBroadcast(newIntent);
它适用于API 16,但不适用于API 23,并且应用程序终止。 我该怎么办?
第二个问题是:如何在没有root的情况下打开和关闭android中的移动数据?
按照文档 Settings.System.AIRPLANE_MODE_ON常数,因为API等级17弃用,并起,这就是为什么你的应用程序崩溃。 您应该改用Settings.Global.AIRPLANE_MODE_ON 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.