当前位置: 首页>>代码示例>>Java>>正文


Java TelephonyManager.getDataState方法代码示例

本文整理汇总了Java中android.telephony.TelephonyManager.getDataState方法的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.getDataState方法的具体用法?Java TelephonyManager.getDataState怎么用?Java TelephonyManager.getDataState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.getDataState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDataState

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
String getDataState(TelephonyManager tm) {
    int state = tm.getDataState();
    mDataState = "undef";
    mDataStateShort = "un";
    switch (state) {
        case TelephonyManager.DATA_DISCONNECTED:
            mDataState = "Disconnected";
            mDataStateShort = "Di";
            break;
        case TelephonyManager.DATA_CONNECTING:
            mDataState = "Connecting";
            mDataStateShort = "Ct";
            break;
        case TelephonyManager.DATA_CONNECTED:
            mDataState = "Connected";
            mDataStateShort = "Cd";
            break;
        case TelephonyManager.DATA_SUSPENDED:
            mDataState = "Suspended";
            mDataStateShort = "Su";
            break;
    }

    return mDataState;
}
 
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:26,代码来源:Device.java

示例2: getNetworkConnectionStatus

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static boolean getNetworkConnectionStatus(Context context) {
	ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
	if (manager == null) {
		return false;
	}

	NetworkInfo info = manager.getActiveNetworkInfo();
	if (info == null) {
		return false;
	}

	TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
	if (tm == null) {
		return false;
	}

	if ((tm.getDataState() == TelephonyManager.DATA_CONNECTED || tm.getDataState() == TelephonyManager.DATA_ACTIVITY_NONE)
			&& info.isAvailable()) {
		return true;
	} else {
		return false;
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:24,代码来源:NetworkUtil.java

示例3: isMobileDataEnabledLollipop

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Boolean isMobileDataEnabledLollipop(){
	TelephonyManager telephonyService = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
       
       switch (telephonyService.getDataState()) {
	case TelephonyManager.DATA_DISCONNECTED:
		Log.i(TAG, "DATA_DISCONNECTED");
		break;
	case TelephonyManager.DATA_CONNECTING:
		Log.i(TAG, "DATA_CONNECTING");
		break;
	case TelephonyManager.DATA_SUSPENDED:
		Log.i(TAG, "DATA_SUSPENDED");
		break;
	case TelephonyManager.DATA_CONNECTED:
		Log.i(TAG, "DATA_CONNECTED");
		return true;
	}

	return false;
}
 
开发者ID:hoanglm4,项目名称:RxAndroidTBP,代码行数:22,代码来源:WifiNetworkUtils.java

示例4: getNetworkConnectionStatus

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static boolean getNetworkConnectionStatus(Context context) {
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (manager == null) {
        return false;
    }

    NetworkInfo info = manager.getActiveNetworkInfo();
    if (info == null) {
        return false;
    }

    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        return false;
    }

    if ((tm.getDataState() == TelephonyManager.DATA_CONNECTED || tm.getDataState() == TelephonyManager.DATA_ACTIVITY_NONE)
            && info.isAvailable()) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:24,代码来源:NetworkUtil.java

示例5: getQualcommTeleInfo

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * Qualcomm Phone.
 * 获取 高通 神机的双卡 IMSI、IMSI 信息
 */
public static TeleInfo getQualcommTeleInfo(Context context) {
    TeleInfo teleInfo = new TeleInfo();
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        Class<?> simTMclass = Class.forName("android.telephony.MSimTelephonyManager");
        Object sim = context.getSystemService("phone_msim");
        int simId_1 = 0;
        int simId_2 = 1;

        Method getSubscriberId = simTMclass.getMethod("getSubscriberId", int.class);
        String imsi_1 = (String) getSubscriberId.invoke(sim, simId_1);
        String imsi_2 = (String) getSubscriberId.invoke(sim, simId_2);
        teleInfo.imsi_1 = imsi_1;
        teleInfo.imsi_2 = imsi_2;

        Method getDeviceId = simTMclass.getMethod("getDeviceId", int.class);
        String imei_1 = (String) getDeviceId.invoke(sim, simId_1);
        String imei_2 = (String) getDeviceId.invoke(sim, simId_2);
        teleInfo.imei_1 = imei_1;
        teleInfo.imei_2 = imei_2;

        Method getDataState = simTMclass.getMethod("getDataState");
        int phoneType_1 = tm.getDataState();
        int phoneType_2 = (Integer) getDataState.invoke(sim);
        teleInfo.phoneType_1 = phoneType_1;
        teleInfo.phoneType_2 = phoneType_2;
    } catch (Exception e) {
        e.printStackTrace();
    }
    ViseLog.i("Qualcomm: " + teleInfo);
    return teleInfo;
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:37,代码来源:TelephoneUtil.java

示例6: getQualcommTeleInfo

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * Qualcomm Phone.
 * 获取 高通 神机的双卡 IMSI、IMSI 信息
 */
public static TeleInfo getQualcommTeleInfo(Context context) {
    TeleInfo teleInfo = new TeleInfo();
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        Class<?> simTMclass = Class.forName("android.telephony.MSimTelephonyManager");
        Object sim = context.getSystemService("phone_msim");
        int simId_1 = 0;
        int simId_2 = 1;

        Method getSubscriberId = simTMclass.getMethod("getSubscriberId", int.class);
        String imsi_1 = (String) getSubscriberId.invoke(sim, simId_1);
        String imsi_2 = (String) getSubscriberId.invoke(sim, simId_2);
        teleInfo.imsi_1 = imsi_1;
        teleInfo.imsi_2 = imsi_2;

        Method getDeviceId = simTMclass.getMethod("getDeviceId", int.class);
        String imei_1 = (String) getDeviceId.invoke(sim, simId_1);
        String imei_2 = (String) getDeviceId.invoke(sim, simId_2);
        teleInfo.imei_1 = imei_1;
        teleInfo.imei_2 = imei_2;

        Method getDataState = simTMclass.getMethod("getDataState");
        int phoneType_1 = tm.getDataState();
        int phoneType_2 = (Integer) getDataState.invoke(sim);
        teleInfo.phoneType_1 = phoneType_1;
        teleInfo.phoneType_2 = phoneType_2;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Log.i(TAG, "Qualcomm: " + teleInfo);
    return teleInfo;
}
 
开发者ID:androidDaniel,项目名称:treasure,代码行数:37,代码来源:TelephoneUtil.java


注:本文中的android.telephony.TelephonyManager.getDataState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。