我正计划挂掉一个电话,我发现这是一种解决办法。如何通过代码激活飞行模式?
通过这种方式,我将基于某个事件来挂断呼叫。
发布于 2010-07-15 02:35:42
请参阅博客文章 ,
最多只能使用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是是否启用飞行模式。
发布于 2012-11-27 04:03:27
请记住,从Android4.2和更高版本开始,这是不可能的。
http://developer.android.com/reference/android/provider/Settings.Global.html#AIRPLANE_MODE_ON
发布于 2012-07-09 18:16:37
public static boolean getAirplaneMode(Context context) {
try {
int airplaneModeSetting = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON);
return airplaneModeSetting==1?true:false;
} catch (SettingNotFoundException e) {
return false;
}
}https://stackoverflow.com/questions/3249245
复制相似问题