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
/** ------------------------------------------------------------------------ Phone Calls -- */ public static boolean deviceCanMakePhoneCall(final Context context) { if (((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number() == null) { // no phone return false; }/*from w w w .j a va2 s . c o m*/ return true; }
From source file:Main.java
/** * get Imei/*w w w . jav a2 s. c o m*/ * @param context * @return imei * */ public static String getIMEI(Context context) { try { TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imei = mTelephonyMgr.getDeviceId(); return imei; } catch (Exception e) { } return null; }
From source file:Main.java
public static String getDeviceID(Activity a) { TelephonyManager tm = (TelephonyManager) a.getApplicationContext() .getSystemService(Context.TELEPHONY_SERVICE); String id = tm.getDeviceId(); if (id == null) id = "DefaultTwitchUser"; return Integer.toHexString(id.hashCode()); }
From source file:Main.java
/** * Checks if is edge.//from w ww . j a v a 2s . c o m * * @param ctx * the ctx * @return true, if is edge */ public static boolean isEdge(final Context ctx) { TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); return tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE; }
From source file:Main.java
/** * Checks if is umts.//from w w w. j a v a2 s . com * * @param ctx * the ctx * @return true, if is umts */ public static boolean isUmts(final Context ctx) { TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); return tm.getNetworkType() >= TelephonyManager.NETWORK_TYPE_UMTS; }
From source file:Main.java
/** * get phone number./*from w w w . j a v a2 s . c o m*/ * * @return phone number. */ public static String getTelePhoneNumber(Context context) { String phoneNumber = ""; TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); phoneNumber = tm.getLine1Number(); return phoneNumber; }
From source file:Main.java
/** * To some SIM card, can not retrieve the phone number * @param context//from w w w .ja va 2s.c o m * @return */ public static String getPhoneNumber(Context context) { TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return telManager.getLine1Number(); }
From source file:Main.java
public static String getImei(Context context) { String imei = ""; try {/*from w ww .j av a 2s. c om*/ TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); imei = telephonyManager.getDeviceId(); } catch (Exception e) { } return imei; }
From source file:Main.java
public static String getCellularNetworkType(Context context) { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); switch (manager.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 .j av a 2s . c o m*/ return ""; } }
From source file:Main.java
public static String getDeviceId(Context context) { if (deviceId == null) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String tmDevice, tmSerial, tmPhone, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); deviceId = deviceUuid.toString(); System.err.println(deviceId); }// w w w . j a v a 2 s . c om return deviceId; }