如何禁用Android的GSM连接编程 [英] How to disable GSM connection in Android programmatically

查看:372
本文介绍了如何禁用Android的GSM连接编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启用/禁用Android手机的GSM连接。我需要禁用/根据需要实现通话和短信。我怎么可以这样做?

I want to enable/disable an Android phone's GSM connection. I need to disable/enable calls and SMS as required. How might I do this?

推荐答案

编辑:该解决方案也将关闭WiFi,蓝牙,等...

This solution will also turn off wifi, bluetooth, etc...

如果你想只关掉收音机,我认为这是与此相关的问题:的 HTTP://$c$c.google.com/p/android/issues/detail ID = 1065 我真的很悲观找到一个很好的解决方案,但好奇,想看看其他的答案。

If you want to turn off radio only, I think it's related to this issue: http://code.google.com/p/android/issues/detail?id=1065 I am really pessimistic about finding a good solution, but curious to see other answers.

请参阅博客文章的 安卓控制飞行模式

See the blog article Android: Controlling Airplane Mode ,

// 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 为飞行模式是否已启用。

where isEnabled is whether airplane mode is enabled or not.

不要忘了你需要的WRITE_SETTINGS许可,要做到这一点,虽然。

Don't forget you need the WRITE_SETTINGS permission to do this, though.

这篇关于如何禁用Android的GSM连接编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆