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


Java TelephonyManager.getNetworkCountryIso方法代碼示例

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


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

示例1: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "honeType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:42,代碼來源:PhoneUtils.java

示例2: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getApp()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:43,代碼來源:PhoneUtils.java

示例3: getUserCountry

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getUserCountry(Context context) {
    try {
        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        final String simCountry = tm.getSimCountryIso();
        if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
            Timber.i(simCountry);
            return simCountry.toLowerCase(Locale.US);
        } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
            String networkCountry = tm.getNetworkCountryIso();
            if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
                return networkCountry.toLowerCase(Locale.US);
            }
        }
    } catch (Exception e) {
        Timber.i(e.getMessage());
    }
    return null;
}
 
開發者ID:prakh25,項目名稱:MovieApp,代碼行數:19,代碼來源:Utils.java

示例4: getCountryRegionFromPhone

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getCountryRegionFromPhone(Context paramContext) {
    TelephonyManager service = (TelephonyManager) paramContext.getSystemService(Context.TELEPHONY_SERVICE);

    String code = null;
    if (service != null) {
        code = service.getNetworkCountryIso();
    }

    if (!HTTextUtils.isEmpty(code)) {
        code = service.getSimCountryIso();
    }

    if (HTTextUtils.isEmpty(code)) {
        code = paramContext.getResources().getConfiguration().locale.getCountry();
    }

    if (code != null) {
        return code.toUpperCase();
    }

    return null;
}
 
開發者ID:hypertrack,項目名稱:hypertrack-live-android,代碼行數:23,代碼來源:Utils.java

示例5: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:43,代碼來源:PhoneUtils.java

示例6: getCountry

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * Get ISO 3166-1 alpha-2 country code for this device (or null if not available)
 *
 * @param context Context reference to getLinkBy the TelephonyManager instance from
 * @return country code or null
 */
public static String getCountry(Context context) {
    try {
        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        final String simCountry = tm.getSimCountryIso();
        if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
            return simCountry.toUpperCase(Locale.US);
        } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
            String networkCountry = tm.getNetworkCountryIso();
            if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
                return networkCountry.toLowerCase(Locale.US);
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "getLinkBy country", e);
    }
    return context.getResources().getConfiguration().locale.getCountry();
}
 
開發者ID:airstep,項目名稱:tubik,代碼行數:24,代碼來源:Tools.java

示例7: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:43,代碼來源:PhoneManager.java

示例8: getNetworkCountryIso

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getNetworkCountryIso(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        return "";
    }
    return "" + tm.getNetworkCountryIso();
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:8,代碼來源:PhoneMessage.java

示例9: getNetworkCountryIso

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * Returns the ISO country code equivalent of the current MCC.
 */
@CalledByNative
private static String getNetworkCountryIso(Context context) {
    TelephonyManager telephonyManager =
            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null) return "";
    return telephonyManager.getNetworkCountryIso();
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:11,代碼來源:AndroidNetworkLibrary.java

示例10: getCountryCode

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
@ReactMethod
public void getCountryCode(Promise promise){
  String isoCountryCode="";
  String mobileCountryCode="";
  String mobileNetworkCode="";
  int callPrefix;

  TelephonyManager manager = (TelephonyManager) this.reactContext.getSystemService(Context.TELEPHONY_SERVICE);
  isoCountryCode = manager.getSimCountryIso();
  
  WritableMap map = Arguments.createMap();
  map.putString("isoCountryCode", isoCountryCode);
  
  mobileCountryCode = manager.getNetworkCountryIso();
  map.putString("mobileCountryCode", mobileCountryCode);

  mobileNetworkCode = manager.getNetworkOperator();
  map.putString("mobileNetworkCode", mobileNetworkCode);

  if(isoCountryCode.length() > 0){
    int index = Arrays.asList(isoCodes).indexOf(isoCountryCode.toUpperCase());
    callPrefix = prefixes[index];
    map.putInt("callPrefix", callPrefix);
  }else{
    map.putString("callPrefix", null);
  }
  promise.resolve(map);
}
 
開發者ID:motius,項目名稱:react-native-telephony-apis,代碼行數:29,代碼來源:RNReactNativeTelephonyModule.java

示例11: getCountryFromPhoneNetwork

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
private String getCountryFromPhoneNetwork() {
	Object o = appContext.getSystemService(TELEPHONY_SERVICE);
	TelephonyManager tm = (TelephonyManager) o;
	return tm.getNetworkCountryIso();
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:6,代碼來源:AndroidLocationUtils.java

示例12: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 * <p>返回如下
 * <pre>
 * DeviceId(IMEI) = 99000311726612
 * DeviceSoftwareVersion = 00
 * Line1Number =
 * NetworkCountryIso = cn
 * NetworkOperator = 46003
 * NetworkOperatorName = 中國電信
 * NetworkType = 6
 * honeType = 2
 * SimCountryIso = cn
 * SimOperator = 46003
 * SimOperatorName = 中國電信
 * SimSerialNumber = 89860315045710604022
 * SimState = 5
 * SubscriberId(IMSI) = 460030419724900
 * VoiceMailNumber = *86
 * <pre/>
 */
public static String getPhoneStatus(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "honeType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:zhuangzaiku,項目名稱:AndroidCollection,代碼行數:44,代碼來源:PhoneUtils.java


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