谷歌Android - 如何计算出,如果3G和2g上开启计算出、谷歌、Android

2023-09-03 22:03:01 作者:孟婆来碗香飘飘

我正在开发一个简单的应用程序对于谷歌Android开启和关闭WiFi或3G或2克。

I'm developing a simple application for the Google Android to turn on and off the wifi or 3g or 2g.

我看的http://developer.android.com/reference/android/net/wifi/WifiManager.html#isWifiEnabled() 你可以看到,如果无线网络启用或禁用,还我们 的http://developer.android.com/reference/android/net/wifi/WifiManager.html#setWifiEnabled(boolean) 接通和断开WIFI

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.

我不知道是否有可能为3G和2G的/ GPRS做? 我知道这是可能的,因为你可以关闭3G和2G留下的。

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.

推荐答案

要确定您的网络使用类型:

2G/3G

To determine your network type use:

TelephonyManager.getNetworkType();

下面是一些例子code:

here's some example code:

bool is3G = (manager.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);

文档的类可以在这里找到:TelephonyManager

要检查您的电话收音机打开或关闭使用:

To check if your telephone radio is on or off use:

ServiceState.getState();

要设置使用:

ServiceState.setState(STATE_POWER_OFF);

目前还不清楚的setState方法是否存在于所有国家的所有设备和功能。没有文档此方法。文档类可以在这里找到:ServiceState

这个问题也可能是相关的:http://$c$c.google.com/p/android/issues/detail?id=1065

This issue might also be relevant: http://code.google.com/p/android/issues/detail?id=1065