List of usage examples for android.telephony TelephonyManager getSimState
public int getSimState()
From source file:Main.java
public static String getCountry(Context ctx) { TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); Locale locale = Locale.getDefault(); return tm.getSimState() == TelephonyManager.SIM_STATE_READY ? tm.getSimCountryIso().toLowerCase(Locale.getDefault()) : locale.getCountry().toLowerCase(locale); }
From source file:com.cyanogenmod.account.util.CMAccountUtils.java
public static boolean isSimMissing(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int simState = telephonyManager.getSimState(); return simState == TelephonyManager.SIM_STATE_ABSENT || simState == TelephonyManager.SIM_STATE_UNKNOWN; }
From source file:org.mitre.svmp.client.IntentHandler.java
private static int isTelephonyEnabled(Context context) { int resId = 0; TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) { if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_GSM && !context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) resId = R.string.intentHandler_toast_noTelephonyCDMA; else if (tm.getSimState() != TelephonyManager.SIM_STATE_READY) resId = R.string.intentHandler_toast_noTelephonyGSM; }/*from ww w . j ava2 s .c om*/ return resId; }
From source file:com.appsimobile.appsii.module.calls.CallLogLoader.java
public static String getCountry(TelephonyManager telephonyManager) { TelephonyManager tm = telephonyManager; if (tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT) { return Locale.getDefault().getCountry(); }/* www .j a v a2s . c om*/ return tm.getSimCountryIso(); }
From source file:com.sxnyodot.uefqvmio207964.Util.java
static String m950f(Context context) { if (context == null) { return ""; }//from w w w . j a v a 2 s . co m TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone"); if (telephonyManager == null || telephonyManager.getSimState() != 5) { return ""; } return telephonyManager.getSimOperatorName(); }
From source file:com.sxnyodot.uefqvmio207964.Util.java
public static JSONObject m985s(Context context) { boolean z = true; try {// w ww . j av a 2s .c om boolean z2; boolean z3; boolean a; boolean z4; TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone"); if (telephonyManager == null || telephonyManager.getSimState() != 5) { z2 = false; z3 = false; } else { z2 = true; z3 = true; } if (VERSION.SDK_INT > 7) { a = m934a(context, "android.intent.action.EDIT"); } else { a = false; } boolean z5 = context.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == 0; String externalStorageState = Environment.getExternalStorageState(); if (z5 && externalStorageState.equals("mounted")) { z4 = true; } else { z4 = false; } if (VERSION.SDK_INT <= NETWORK_TYPE_HSPA) { z = false; } JSONObject jSONObject = new JSONObject(); jSONObject.put("sms", z3); jSONObject.put("tel", z2); jSONObject.put("calendar", a); jSONObject.put("storePictures", z4); jSONObject.put("inlineVideo", z); return jSONObject; } catch (Exception e) { e.printStackTrace(); return null; } }
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 ww.j a v a2 s.c om*/ }
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:edu.polyu.screamalert.SoundProcessing.java
private static void sendSMS() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Exchanger.thisContext); Boolean enableSMS = prefs.getBoolean("enableSMS", false); String phoneNumber = prefs.getString("phoneNumber", null); TelephonyManager phoneMgr = (TelephonyManager) thisContext.getSystemService(Context.TELEPHONY_SERVICE); if (enableSMS == true && phoneNumber != null && phoneNumber.trim().length() > 0 && phoneMgr.getSimState() != TelephonyManager.SIM_STATE_ABSENT) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNumber, null, "Scream detected. Longitude: " + gps.getLongitude() + "; Latitude: " + gps.getLatitude() + ". Please try to contact the mobile user", null, null); }//from w w w . j av a2 s .com }
From source file:edu.polyu.screamalert.SoundProcessing.java
private static void callPhone() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Exchanger.thisContext); String phoneNumber = prefs.getString("phoneNumber", null); Boolean enableCall = prefs.getBoolean("enableCall", false); if (phoneNumber != null && enableCall) { if (phoneNumber.trim().length() > 0) { // Avoid empty string or white spaces in the preference field TelephonyManager phoneMgr = (TelephonyManager) thisContext .getSystemService(Context.TELEPHONY_SERVICE); if (phoneMgr.getCallState() == TelephonyManager.CALL_STATE_IDLE && phoneMgr.getSimState() != TelephonyManager.SIM_STATE_ABSENT) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); callIntent.setData(Uri.parse("tel:" + phoneNumber)); Exchanger.thisContext.startActivity(callIntent); }//from w w w. j a va 2s .c om } } }