谷歌Android - 如何计算出,如果3G和2g上开启 [英] Google Android - how to figure out if 3g and 2g is turned on

查看:159
本文介绍了谷歌Android - 如何计算出,如果3G和2g上开启的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的应用程序对于谷歌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);

文档的类可以在这里找到:<一href="http://developer.android.com/reference/android/telephony/TelephonyManager.html">TelephonyManager


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

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

ServiceState.getState();

要设置使用:

ServiceState.setState(STATE_POWER_OFF);

目前还不清楚的setState方法是否存在于所有国家的所有设备和功能。没有文档此方法。文档类可以在这里找到:<一href="http://developer.android.com/reference/android/telephony/ServiceState.html">ServiceState

这个问题也可能是相关的:<一href="http://$c$c.google.com/p/android/issues/detail?id=1065">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

这篇关于谷歌Android - 如何计算出,如果3G和2g上开启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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