android - 如何在 Android 中以编程方式将手机置于飞行模式?

标签 android audio application-settings appsettings android-audiomanager

谁能告诉我如何通过单击 android 中的按钮以编程方式将手机置于飞行模式?

最佳答案

参见博客文章 http://dustinbreese.blogspot.in/2009/04/andoid-controlling-airplane-mode.html ,

仅适用于 API 16

// Toggle airplane mode.
Settings.System.putInt(
      context.getContentResolver(),
      Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);

// Post an intent to reload.
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", !isEnabled);
sendBroadcast(intent);

其中 isEnabled 是飞行模式是否启用。

关于android - 如何在 Android 中以编程方式将手机置于飞行模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19953432/

相关文章:

javascript - 将字符串转换为JS对象

c# - 应用程序设置中的 StringCollection 未存储

生成弹出消息时android振动或发出哔哔声

java - 从 Android 客户端使用 POST 向 java 服务器发送数据并获取 JSON 响应

javascript - react-native-router-flux 不路由

c# - 有人可以提供快速的 App.config/Web.config 教程吗?

c# - 遍历设置文件

java - Android:WebView:更改提交(GET)请求的 HTML

android - 上传音视频文件到服务器

javascript - 可视化 html5 音频