List of usage examples for android.telephony TelephonyManager getNetworkOperator
public String getNetworkOperator()
From source file:Main.java
public static String getNetworkOperator(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getNetworkOperator(); }
From source file:Main.java
public static String getNetworkOperator(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return telephonyManager.getNetworkOperator(); }
From source file:Main.java
public static String getNetWorkOperator(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) { return tm.getNetworkOperator(); }/*from ww w .j a v a2 s . com*/ return ""; }
From source file:Main.java
public static String getMnc(Context mContext) { String mnc = ""; TelephonyManager telephoneyManager = (TelephonyManager) mContext .getSystemService(Context.TELEPHONY_SERVICE); String MC = telephoneyManager.getNetworkOperator(); if (MC.length() >= 5) { mnc = MC.substring(3, 5);//w w w. j a v a 2 s. c o m } return mnc; }
From source file:Main.java
public static String[] getNetworkOperatorCodes(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String simOperator = telephonyManager.getNetworkOperator(); String[] mccmnc = new String[] { null, null }; if (!TextUtils.isEmpty(simOperator)) { mccmnc[0] = simOperator.substring(0, 3); mccmnc[1] = simOperator.substring(3); }/* w w w . ja v a 2 s. c om*/ return mccmnc; }
From source file:Main.java
public static String queryDevicePhone(Context context) { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (manager != null) { operatorCode = manager.getNetworkOperator(); if (operatorCode == null || operatorCode.length() == 0) operatorCode = manager.getSimOperator(); isoCountryCode = manager.getNetworkCountryIso(); if (isoCountryCode == null || isoCountryCode.length() == 0) isoCountryCode = manager.getSimCountryIso(); if (isoCountryCode == null || isoCountryCode.length() == 0) isoCountryCode = context.getResources().getConfiguration().locale.getCountry(); }/*from w ww . jav a 2 s. c o m*/ return manager.getLine1Number(); }
From source file:totalcross.android.ConnectionManager4A.java
public static void setDefaultConfiguration(int type, String cfg) { if (cfg == null) cfg = ""; switch (type) { case GPRS: {/* w ww. ja v a 2s .c om*/ int id = -1; ContentResolver contentResolver = Launcher4A.loader.getContentResolver(); Cursor cursor = contentResolver.query(CONTENT_URI, new String[] { "_id" }, "apn = ? and user = ? and password = ?", new String[] { "tim.br", "tim", "tim" }, null); if (cursor == null || cursor.getCount() <= 0) { TelephonyManager tel = (TelephonyManager) Launcher4A.loader .getSystemService(Context.TELEPHONY_SERVICE); String networkOperator = tel.getNetworkOperator(); if (networkOperator != null && networkOperator.length() > 0) { int mcc = Integer.parseInt(networkOperator.substring(0, 3)); int mnc = Integer.parseInt(networkOperator.substring(3)); ContentValues values = new ContentValues(); values.put("apn", "tim.br"); values.put("user", "tim"); values.put("password", "tim"); values.put("mcc", mcc); values.put("mnc", mnc); values.put("numeric", mcc + "" + mnc); contentResolver.insert(CONTENT_URI, values); cursor = contentResolver.query(CONTENT_URI, new String[] { "_id" }, "apn = ? and user = ? and password = ?", new String[] { "tim.br", "tim", "tim" }, null); } } if (cursor == null) return; if (cursor.moveToFirst()) id = cursor.getInt(0); cursor.close(); if (id > -1) { ContentValues values = new ContentValues(); //See /etc/apns-conf.xml. The TelephonyProvider uses this file to provide //content://telephony/carriers/preferapn URI mapping values.put("apn_id", id); contentResolver.update(PREFERRED_APN_URI, values, null, null); cursor = contentResolver.query(PREFERRED_APN_URI, new String[] { "name", "apn" }, "_id=" + id, null, null); if (cursor != null) cursor.close(); } } break; case WIFI: connWIFI = connWIFIPrefix + cfg; break; //default: // throw new IllegalArgumentException("Invalid value for argument 'type'"); } }
From source file:Main.java
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;// w w w . ja v a 2 s .c o m }
From source file:Main.java
public static String getDeviceInfo(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); StringBuilder sb = new StringBuilder(); sb.append("\nDeviceId(IMEI) = " + tm.getDeviceId()); sb.append("\nDeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()); sb.append("\nLine1Number = " + tm.getLine1Number()); sb.append("\nNetworkCountryIso = " + tm.getNetworkCountryIso()); sb.append("\nNetworkOperator = " + tm.getNetworkOperator()); sb.append("\nNetworkOperatorName = " + tm.getNetworkOperatorName()); sb.append("\nNetworkType = " + tm.getNetworkType()); sb.append("\nPhoneType = " + tm.getPhoneType()); sb.append("\nSimCountryIso = " + tm.getSimCountryIso()); sb.append("\nSimOperator = " + tm.getSimOperator()); sb.append("\nSimOperatorName = " + tm.getSimOperatorName()); sb.append("\nSimSerialNumber = " + tm.getSimSerialNumber()); sb.append("\nSimState = " + tm.getSimState()); sb.append("\nSubscriberId(IMSI) = " + tm.getSubscriberId()); sb.append("\nVoiceMailNumber = " + tm.getVoiceMailNumber()); return sb.toString(); }
From source file:com.wbtech.common.CommonUtil.java
/** * ??//from w w w.j av a2 s . c o m * @throws Exception */ public static SCell getCellInfo(Context context) throws Exception { SCell cell = new SCell(); /** API?? */ TelephonyManager mTelNet = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); GsmCellLocation location = (GsmCellLocation) mTelNet.getCellLocation(); if (location == null) { if (UmsConstants.DebugMode) { Log.e("GsmCellLocation Error", "GsmCellLocation is null"); } return null; } String operator = mTelNet.getNetworkOperator(); // System.out.println("operator------>"+operator.toString()); int mcc = Integer.parseInt(operator.substring(0, 3)); int mnc = Integer.parseInt(operator.substring(3)); int cid = location.getCid(); int lac = location.getLac(); /** ? */ cell.MCC = mcc; cell.MCCMNC = Integer.parseInt(operator); cell.MNC = mnc; cell.LAC = lac; cell.CID = cid; return cell; }