當前位置: 首頁>>代碼示例>>Java>>正文


Java TelephonyManager.isNetworkRoaming方法代碼示例

本文整理匯總了Java中android.telephony.TelephonyManager.isNetworkRoaming方法的典型用法代碼示例。如果您正苦於以下問題:Java TelephonyManager.isNetworkRoaming方法的具體用法?Java TelephonyManager.isNetworkRoaming怎麽用?Java TelephonyManager.isNetworkRoaming使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.isNetworkRoaming方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isNetworkRoaming

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
@Override
public boolean isNetworkRoaming() {
    ConnectivityManager connectivity =
            (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity == null) {
        Log.w(TAG, "couldn't get connectivity manager");
        return false;
    }

    NetworkInfo info = connectivity.getActiveNetworkInfo();
    boolean isMobile = (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE);
    TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    boolean isRoaming = isMobile && tm.isNetworkRoaming();
    if (Constants.LOGVV && isRoaming) {
        Log.v(TAG, "network is roaming");
    }
    return isRoaming;
}
 
開發者ID:redleaf2002,項目名稱:downloadmanager,代碼行數:19,代碼來源:RealSystemFacade.java

示例2: isNetworkRoaming

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 判斷網絡是否為漫�?
 */
public static boolean isNetworkRoaming(Context context) {
    ConnectivityManager connectivity = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity == null) {
        Log.w(LOG_TAG, "couldn't get connectivity manager");
    } else {
        NetworkInfo info = connectivity.getActiveNetworkInfo();
        if (info != null
                && info.getType() == ConnectivityManager.TYPE_MOBILE) {
            TelephonyManager tm = (TelephonyManager) context
                    .getSystemService(Context.TELEPHONY_SERVICE);
            if (tm != null && tm.isNetworkRoaming()) {
                Log.d(LOG_TAG, "network is roaming");
                return true;
            } else {
                Log.d(LOG_TAG, "network is not roaming");
            }
        } else {
            Log.d(LOG_TAG, "not using mobile network");
        }
    }
    return false;
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:27,代碼來源:NetWorkHelper.java

示例3: isNetworkRoaming

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public boolean isNetworkRoaming() {
    ConnectivityManager connectivity =
            (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity == null) {
        Log.w(Constants.TAG, "couldn't get connectivity manager");
        return false;
    }

    NetworkInfo info = connectivity.getActiveNetworkInfo();
    boolean isMobile = (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE);
    TelephonyManager tm = (TelephonyManager) mContext
            .getSystemService(Context.TELEPHONY_SERVICE);
    if (null == tm) {
        Log.w(Constants.TAG, "couldn't get telephony manager");
        return false;
    }
    boolean isRoaming = isMobile && tm.isNetworkRoaming();
    if (Constants.LOGVV && isRoaming) {
        Log.v(Constants.TAG, "network is roaming");
    }
    return isRoaming;
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:23,代碼來源:SystemFacade.java

示例4: getAPNType

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取當前的網絡狀態 :沒有網絡-0:WIFI網絡1:4G網絡-4:3G網絡-3:2G網絡-2
 * 自定義
 *
 * @param context
 * @return
 */
public static int getAPNType(Context context) {
    //結果返回值
    int netType = 0;
    //獲取手機所有連接管理對象
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    //獲取NetworkInfo對象
    NetworkInfo networkInfo = manager.getActiveNetworkInfo();
    //NetworkInfo對象為空 則代表沒有網絡
    if (networkInfo == null) {
        return netType;
    }
    //否則 NetworkInfo對象不為空 則獲取該networkInfo的類型
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_WIFI) {
        //WIFI
        netType = 1;
    } else if (nType == ConnectivityManager.TYPE_MOBILE) {
        int nSubType = networkInfo.getSubtype();
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        //3G   聯通的3G為UMTS或HSDPA 電信的3G為EVDO
        if (nSubType == TelephonyManager.NETWORK_TYPE_LTE
                && !telephonyManager.isNetworkRoaming()) {
            netType = 4;
        } else if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS
                || nSubType == TelephonyManager.NETWORK_TYPE_HSDPA
                || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_0
                && !telephonyManager.isNetworkRoaming()) {
            netType = 3;
            //2G 移動和聯通的2G為GPRS或EGDE,電信的2G為CDMA
        } else if (nSubType == TelephonyManager.NETWORK_TYPE_GPRS
                || nSubType == TelephonyManager.NETWORK_TYPE_EDGE
                || nSubType == TelephonyManager.NETWORK_TYPE_CDMA
                && !telephonyManager.isNetworkRoaming()) {
            netType = 2;
        } else {
            netType = 2;
        }
    }
    return netType;
}
 
開發者ID:Mrqinlei,項目名稱:ImitateZHRB,代碼行數:48,代碼來源:NetworkUtils.java

示例5: getAPNType

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取當前的網絡狀態 :沒有網絡-0:WIFI網絡1:4G網絡-4:3G網絡-3:2G網絡-2
 * 自定義
 */
public static int getAPNType(Context context) {
    //結果返回值
    int netType = 0;
    //獲取手機所有連接管理對象
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context
            .CONNECTIVITY_SERVICE);
    //獲取NetworkInfo對象
    NetworkInfo networkInfo = manager.getActiveNetworkInfo();
    //NetworkInfo對象為空 則代表沒有網絡
    if (networkInfo == null) {
        return netType;
    }
    //否則 NetworkInfo對象不為空 則獲取該networkInfo的類型
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_WIFI) {
        //WIFI
        netType = 1;
    } else if (nType == ConnectivityManager.TYPE_MOBILE) {
        int nSubType = networkInfo.getSubtype();
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService
                (Context.TELEPHONY_SERVICE);
        //3G   聯通的3G為UMTS或HSDPA 電信的3G為EVDO
        if (nSubType == TelephonyManager.NETWORK_TYPE_LTE
                && !telephonyManager.isNetworkRoaming()) {
            netType = 4;
        } else if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS
                || nSubType == TelephonyManager.NETWORK_TYPE_HSDPA
                || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_0
                && !telephonyManager.isNetworkRoaming()) {
            netType = 3;
            //2G 移動和聯通的2G為GPRS或EGDE,電信的2G為CDMA
        } else if (nSubType == TelephonyManager.NETWORK_TYPE_GPRS
                || nSubType == TelephonyManager.NETWORK_TYPE_EDGE
                || nSubType == TelephonyManager.NETWORK_TYPE_CDMA
                && !telephonyManager.isNetworkRoaming()) {
            netType = 2;
        } else {
            netType = 2;
        }
    }
    return netType;
}
 
開發者ID:fendoudebb,項目名稱:PlayAndroid,代碼行數:47,代碼來源:NetworkUtil.java


注:本文中的android.telephony.TelephonyManager.isNetworkRoaming方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。