List of usage examples for android.telephony TelephonyManager getPhoneType
public int getPhoneType()
From source file:tw.com.ksmt.cloud.libs.Utils.java
/** * Get ISO 3166-1 alpha-2 country code for this device (or null if not available) * * @param context Context reference to get the TelephonyManager instance from * @return country code or null//from w ww.j a v a 2 s.c om */ public static String getCountryBySIM(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.toUpperCase(Locale.US); } } } catch (Exception e) { } return null; }
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.sxnyodot.uefqvmio207964.Util.java
static String m953g(Context context) { if (context == null) { return ""; }/*from w ww .j a va2s . co m*/ TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone"); if (telephonyManager == null || telephonyManager.getPhoneType() != 1) { return ""; } return telephonyManager.getNetworkOperatorName(); }
From source file:ru.dublgis.androidhelpers.DesktopUtils.java
public static boolean isVoiceTelephonyAvailable(final Context ctx) { try {// w w w . ja v a 2 s. co m if (!ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { return false; } final TelephonyManager manager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); if (manager == null) { return false; } if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { return false; } if (Build.VERSION.SDK_INT >= 22) // Android 5.1+ { if (!manager.isVoiceCapable()) { return false; } } return true; } catch (final Throwable e) { Log.e(TAG, "isVoiceTelephonyAvailable exception (will return 'false'): ", e); return false; } }
From source file:ca.psiphon.PsiphonTunnel.java
private static String getDeviceRegion(Context context) { String region = ""; TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager != null) { region = telephonyManager.getSimCountryIso(); if (region == null) { region = ""; }/*from w w w .ja v a 2s . c o m*/ if (region.length() == 0 && telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { region = telephonyManager.getNetworkCountryIso(); if (region == null) { region = ""; } } } if (region.length() == 0) { Locale defaultLocale = Locale.getDefault(); if (defaultLocale != null) { region = defaultLocale.getCountry(); } } return region.toUpperCase(Locale.US); }
From source file:fr.inria.ucn.listeners.MyPhoneStateListener.java
/** * //w w w . j a v a 2s . c o m * @param c */ public void disable(Context c) { TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE); if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE) { tm.listen(this, PhoneStateListener.LISTEN_NONE); this.c = null; } // else no telephony }
From source file:fr.inria.ucn.listeners.MyPhoneStateListener.java
/** * // w w w . j a v a2 s.c om * @param c */ public void enable(Context c) { TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE); if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE) { tm.listen(this, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); this.c = c; } // else no telephony }
From source file:com.fallahpoor.infocenter.fragments.SimFragment.java
private String getPhoneType(TelephonyManager telephonyManager) { int phoneTypeInt = telephonyManager.getPhoneType(); String phoneTypeStr;/*from ww w. j a v a 2 s . c o m*/ switch (phoneTypeInt) { case TelephonyManager.PHONE_TYPE_CDMA: phoneTypeStr = getString(R.string.sim_sub_item_cdma); break; case TelephonyManager.PHONE_TYPE_GSM: phoneTypeStr = getString(R.string.sim_sub_item_gsm); break; case TelephonyManager.PHONE_TYPE_SIP: phoneTypeStr = getString(R.string.sim_sub_item_sip); break; default: phoneTypeStr = getString(R.string.unknown); } return phoneTypeStr; }
From source file:org.mozilla.mozstumbler.service.stumblerthread.Reporter.java
public synchronized void startup(Context context) { if (mIsStarted) { return;/*from www .ja v a2 s. com*/ } mContext = context.getApplicationContext(); TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mPhoneType = tm.getPhoneType(); mIsStarted = true; mBundle = null; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiScanner.ACTION_WIFIS_SCANNED); intentFilter.addAction(CellScanner.ACTION_CELLS_SCANNED); intentFilter.addAction(GPSScanner.ACTION_GPS_UPDATED); intentFilter.addAction(ACTION_FLUSH_TO_BUNDLE); LocalBroadcastManager.getInstance(mContext).registerReceiver(this, intentFilter); }
From source file:com.fallahpoor.infocenter.fragments.SimFragment.java
private boolean isSimPresent() { TelephonyManager telephonyManager = (TelephonyManager) getActivity() .getSystemService(Context.TELEPHONY_SERVICE); return (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM && telephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT); }