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
private static String getOperators(Context context) { TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tel == null ? "" : tel.getSimOperator(); }
From source file:Main.java
public static String getIMEI(Context ctx) { return ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); }
From source file:Main.java
public static String getPhoneNumber(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getLine1Number(); }
From source file:Main.java
public static String getPhoneImei(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imei = tm.getDeviceId(); return imei;/*from w ww . jav a 2 s . c o m*/ }
From source file:Main.java
public static String getDeviceImsi(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm == null) { return "null"; } else {/*from ww w . j av a 2s.c o m*/ String id = tm.getSubscriberId(); return id == null ? "null" : id; } }
From source file:Main.java
public static String getDeviceId(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm == null) { return "null"; } else {/*w w w . j a v a2 s .c om*/ String id = tm.getDeviceId(); return id == null ? "null" : id; } }
From source file:Main.java
public static int getPhoneType(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm != null ? tm.getPhoneType() : -1; }
From source file:Main.java
/** * Get unique device info./*from w w w . jav a 2 s .c o m*/ * * @param context application context. * @return returns a json object of the device, manufacturer, build version, and a unique id. */ public static JSONObject getDeviceInfo(Context context) { JSONObject deviceInfo = new JSONObject(); try { deviceInfo.put("device", Build.MODEL); deviceInfo.put("manufacturer", Build.MANUFACTURER); deviceInfo.put("android", android.os.Build.VERSION.SDK); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String tmDevice = tm.getDeviceId(); String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); String serial = null; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) serial = Build.SERIAL; if (androidId != null) deviceInfo.put("uid", androidId); else if (serial != null) deviceInfo.put("uid", serial); else if (tmDevice != null) deviceInfo.put("uid", tmDevice); deviceInfo.put("carrier", tm.getNetworkOperatorName()); } catch (JSONException e) { e.printStackTrace(); } return deviceInfo; }
From source file:Main.java
public static String getPhoneNumber(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm == null) { return "null"; } else {/*from w ww . j av a2 s. c o m*/ String number = tm.getLine1Number(); return number; } }
From source file:Main.java
private static String getNumber(Context ctx) { TelephonyManager tMgr = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); return tMgr.getLine1Number(); }