Google Android - 如何确定 3g 和 2g 是否已打开
我正在为 Google Android 开发一个简单的应用程序来打开和关闭 wifi 或 3g 或 2g。
我看到 http://developer.android.com/参考/android/net/wifi/WifiManager.html#isWifiEnabled() 您可以查看 wifi 是否启用或禁用以及我们 http://developer.android.com/reference /android/net/wifi/WifiManager.html#setWifiEnabled(boolean) 打开和关闭 wifi。
我想知道是否可以对 3G 和 2G/GPRS 做同样的事情? 我知道这是可能的,因为您可以关闭 3G 并保留 2G。
I'm developing a simple application for the Google Android to turn on and off the wifi or 3g or 2g.
I see http://developer.android.com/reference/android/net/wifi/WifiManager.html#isWifiEnabled()
that you can see if the wifi is enabled or disabled and also us
http://developer.android.com/reference/android/net/wifi/WifiManager.html#setWifiEnabled(boolean)
to turn on and off the wifi.
I'm wondering if it's possible to do the same for 3G and for 2G/GPRS?
I know it's possible because you can turn off 3G and left 2G on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
2G/3G
要确定您的网络类型使用:
这里有一些示例代码:
该类的文档可以在以下位置找到:TelephonyManager
开/关
要检查您的电话收音机是否打开或关闭,请使用:
要设置它,请使用:
目前尚不清楚 setState 方法是否存在于所有设备和所有状态下的功能上。 没有关于此方法的文档。 该类的文档可以在以下位置找到: ServiceState
此问题也可能是相关:http://code.google.com/p/android/issues /detail?id=1065
2G/3G
To determine your network type use:
here's some example code:
Docs for the class can be found at: TelephonyManager
On/Off
To check if your telephone radio is on or off use:
To set it use:
It's unclear whether the setState method exists on all devices and functions in all states. There is no documentation for this method. Documentation for the class can be found at: ServiceState
This issue might also be relevant: http://code.google.com/p/android/issues/detail?id=1065
您还可以使用 ConnectivityManager。 像这样的东西:
You can also use ConnectivityManager. Something like that: