本文整理了Java中android.telephony.TelephonyManager.getNetworkType()
方法的一些代码示例,展示了TelephonyManager.getNetworkType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getNetworkType()
方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getNetworkType
暂无
代码示例来源:origin: stackoverflow.com
public String getNetworkClass(Context context) {
TelephonyManager mTelephonyManager = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
int networkType = mTelephonyManager.getNetworkType();
switch (networkType) {
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_EDGE:
case TelephonyManager.NETWORK_TYPE_CDMA:
case TelephonyManager.NETWORK_TYPE_1xRTT:
case TelephonyManager.NETWORK_TYPE_IDEN:
return "2G";
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_EVDO_0:
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_EVDO_B:
case TelephonyManager.NETWORK_TYPE_EHRPD:
case TelephonyManager.NETWORK_TYPE_HSPAP:
return "3G";
case TelephonyManager.NETWORK_TYPE_LTE:
return "4G";
default:
return "Unknown";
}
}
代码示例来源:origin: jdsjlzx/LRecyclerView
private static boolean isFastMobileNetwork(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
switch (telephonyManager.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_1xRTT:
return false; // ~ 50-100 kbps
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
return "TM==null";
switch (telephonyManager.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_1xRTT:// ~ 50-100 kbps
return "2G";
代码示例来源:origin: Rukey7/MvpApp
switch (telephonyManager.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_1xRTT:
return false;
代码示例来源:origin: Rukey7/MvpApp
switch (telephonyManager.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_1xRTT:
return false;
代码示例来源:origin: stackoverflow.com
TelephonyManager mTelephonyManager = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
int networkType = mTelephonyManager.getNetworkType();
switch (networkType) {
case TelephonyManager.NETWORK_TYPE_GPRS:
代码示例来源:origin: square/assertj-android
public TelephonyManagerAssert hasNetworkType(@TelephonyManagerNetworkType int type) {
isNotNull();
int actualType = actual.getNetworkType();
//noinspection ResourceType
assertThat(actualType) //
.overridingErrorMessage("Expected network type <%s> but was <%s>.",
networkTypeToString(type), networkTypeToString(actualType)) //
.isEqualTo(type);
return this;
}
代码示例来源:origin: jiajunhui/PlayerBase
int networkType = telephonyManager.getNetworkType();
switch (networkType) {
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldGiveNetworkType() {
shadowOf(telephonyManager).setNetworkType(TelephonyManager.NETWORK_TYPE_CDMA);
assertEquals(TelephonyManager.NETWORK_TYPE_CDMA, telephonyManager.getNetworkType());
}
代码示例来源:origin: stackoverflow.com
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int networkType = telephonyManager.getNetworkType();
代码示例来源:origin: stackoverflow.com
// check for wifi or 3g
ConnectivityManager mgrConn = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mgrTel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if ((mgrConn.getActiveNetworkInfo()!=null && mgrConn.getActiveNetworkInfo().getState()==NetworkInfo.State.CONNECTED)
|| mgrTel.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS) {
...
代码示例来源:origin: stackoverflow.com
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
int dbm = 0;
if ( tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE){
// For Lte SignalStrength: dbm = ASU - 140.
dbm = Integer.parseInt(parts[8])-140;
}
else{
// For GSM Signal Strength: dbm = (2*ASU)-113.
if (signalStrength.getGsmSignalStrength() != 99) {
int intdbm = -113 + 2
* signalStrength.getGsmSignalStrength();
dbm = Integer.toString(intdbm);
}
}
代码示例来源:origin: stackoverflow.com
int networkType = teleMan.getNetworkType();
代码示例来源:origin: stackoverflow.com
/**
* Check if there is fast connectivity
* @param context
* @return
*/
public static boolean isConnectedFast(Context context){
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return (info != null && info.isConnected() && Connectivity.isConnectionFast(info.getType(), tm.getNetworkType()));
}
代码示例来源:origin: stackoverflow.com
TelephonyManager teleMan = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
int networkType = teleMan.getNetworkType();
switch (networkType) {
case TelephonyManager.NETWORK_TYPE_1xRTT: return "1xRTT";
代码示例来源:origin: limedroid/XDroidMvp
switch (telephonyManager.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_1xRTT:
return false;
代码示例来源:origin: stackoverflow.com
} else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
return tm.getNetworkType();
代码示例来源:origin: gslovemy/RxJavaRetrofitOkhttpMvp
/**
* is wifi on
*/
public static boolean isWifiEnabled(Context context) {
ConnectivityManager mgrConn = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mgrTel = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return ((mgrConn.getActiveNetworkInfo() != null && mgrConn
.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED) || mgrTel
.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
}
代码示例来源:origin: LRH1993/RetrofitRxJavaBox
/**
* is wifi on
*/
public static boolean isWifiEnabled(Context context) {
ConnectivityManager mgrConn = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mgrTel = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return ((mgrConn.getActiveNetworkInfo() != null && mgrConn
.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED) || mgrTel
.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
}
代码示例来源:origin: majunm/HttpX
/**
* get network type by {@link TelephonyManager}
* <p>
* such as 2G, 3G, 4G, etc.
*
* @return {@link TelephonyManager#NETWORK_TYPE_CDMA}, {@link TelephonyManager#NETWORK_TYPE_GPRS},
* {@link TelephonyManager#NETWORK_TYPE_LTE}...
*/
public static int getTelNetworkTypeINT(Context context) {
return getTelephonyManager(context).getNetworkType();
}
内容来源于网络,如有侵权,请联系作者删除!