當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。