List of usage examples for android.content Context TELEPHONY_SERVICE
String TELEPHONY_SERVICE
To view the source code for android.content Context TELEPHONY_SERVICE.
Click Source Link
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 w w . j a v a 2 s. co m return manager.getLine1Number(); }
From source file:Main.java
/** * this device has phone radio?/*from www .ja v a 2 s. c o m*/ * * @param context * @return */ public static boolean isPhone(Context context) { TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int type = telephony.getPhoneType(); if (type == TelephonyManager.PHONE_TYPE_NONE) { return false; } else { return true; } }
From source file:Main.java
public static String getNetworkType(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); switch (telephonyManager.getNetworkType()) { case TelephonyManager.NETWORK_TYPE_1xRTT: return "1xRTT"; case TelephonyManager.NETWORK_TYPE_CDMA: return "CDMA"; case TelephonyManager.NETWORK_TYPE_EDGE: return "EDGE "; case TelephonyManager.NETWORK_TYPE_EHRPD: return "EHRPD "; case TelephonyManager.NETWORK_TYPE_EVDO_0: return "EVDO_0 "; case TelephonyManager.NETWORK_TYPE_EVDO_A: return "EVDO_A "; case TelephonyManager.NETWORK_TYPE_EVDO_B: return "EVDO_B "; case TelephonyManager.NETWORK_TYPE_GPRS: return "GPRS "; case TelephonyManager.NETWORK_TYPE_HSDPA: return "HSDPA "; case TelephonyManager.NETWORK_TYPE_HSPA: return "HSPA "; case TelephonyManager.NETWORK_TYPE_HSPAP: return "HSPAP "; case TelephonyManager.NETWORK_TYPE_HSUPA: return "HSUPA "; case TelephonyManager.NETWORK_TYPE_IDEN: return "IDEN "; case TelephonyManager.NETWORK_TYPE_LTE: return "LTE "; case TelephonyManager.NETWORK_TYPE_UMTS: return "UMTS "; case TelephonyManager.NETWORK_TYPE_UNKNOWN: return "UNKNOWN "; default:/*from w w w .jav a 2s . c o m*/ return "UNKNOWN "; } }
From source file:Main.java
public static String getDeviceId(Context context) { if (TextUtils.isEmpty(DEVICE_ID)) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); DEVICE_ID = tm.getDeviceId();// w ww .j ava2s. c o m } return DEVICE_ID; }
From source file:Main.java
public static String getDeviceId(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String deviceId = tm.getDeviceId(); String macAddress = getMacAddress(); return deviceId + "-" + macAddress; }
From source file:Main.java
/** * Returns the device ID/*from w ww. j a v a 2 s.co m*/ * * @param context A valid context instance * @return the device ID */ @SuppressWarnings("unused") public static String getDeviceId(Context context) { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return manager.getDeviceId(); }
From source file:Main.java
public static String getCountryISOFromSimCard(final Context context) { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getSimCountryIso(); }
From source file:Main.java
public static String getDeviceInfo(Context context) { try {//from w w w.jav a2s . com org.json.JSONObject json = new org.json.JSONObject(); android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String device_id = tm.getDeviceId(); android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context .getSystemService(Context.WIFI_SERVICE); String mac = wifi.getConnectionInfo().getMacAddress(); json.put("mac", mac); if (TextUtils.isEmpty(device_id)) { device_id = mac; } if (TextUtils.isEmpty(device_id)) { device_id = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); } json.put("device_id", device_id); return json.toString(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String getDeviceId(Context ctx) { StringBuilder sbuff = new StringBuilder(); TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); /*/* ww w . ja v a 2 s . co m*/ * getDeviceId() function Returns the unique device ID. * for example,the IMEI for GSM and the MEID or ESN for CDMA phones. */ String imeistring = telephonyManager.getDeviceId(); sbuff.append(imeistring + DELIMITER); /* * getSubscriberId() function Returns the unique subscriber ID, * for example, the IMSI for a GSM phone. */ String imsistring = telephonyManager.getSubscriberId(); sbuff.append(imsistring + DELIMITER); /* * Settings.Secure.ANDROID_ID returns the unique DeviceID * Works for Android 2.2 and above */ String androidId = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID); sbuff.append(androidId); //Log.d("deep link device id", sbuff.toString()+""); return (sbuff.toString()); }
From source file:Main.java
public static boolean isWiFiEnabled(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return ((cm != null && cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED) || tm != null && tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS); }