List of usage examples for android.telephony TelephonyManager getSubscriberId
@SuppressAutoDoc
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getSubscriberId()
From source file:xj.property.ums.UmsAgent.java
public static JSONObject getClientDataJSONObject(Context context) { TelephonyManager tm = (TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE)); WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics displaysMetrics = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(displaysMetrics); LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); JSONObject clientData = new JSONObject(); try {// w w w . j a va2s .co m clientData.put("os_version", CommonUtil.getOsVersion(context)); clientData.put("platform", "android"); clientData.put("language", Locale.getDefault().getLanguage()); clientData.put("deviceid", tm.getDeviceId() == null ? "" : tm.getDeviceId());// clientData.put("appkey", CommonUtil.getAppKey(context)); clientData.put("resolution", displaysMetrics.widthPixels + "x" + displaysMetrics.heightPixels); clientData.put("ismobiledevice", true); clientData.put("phonetype", tm.getPhoneType());// clientData.put("imsi", tm.getSubscriberId()); clientData.put("network", CommonUtil.getNetworkTypeWIFI2G3G(context)); clientData.put("time", CommonUtil.getTime()); clientData.put("version", CommonUtil.getVersion(context)); clientData.put(UserIdentifier, CommonUtil.getUserIdentifier(context)); SCell sCell = CommonUtil.getCellInfo(context); clientData.put("mccmnc", sCell != null ? "" + sCell.MCCMNC : ""); clientData.put("cellid", sCell != null ? sCell.CID + "" : ""); clientData.put("lac", sCell != null ? sCell.LAC + "" : ""); clientData.put("modulename", Build.PRODUCT); clientData.put("devicename", CommonUtil.getDeviceName()); clientData.put("wifimac", wifiManager.getConnectionInfo().getMacAddress()); clientData.put("havebt", adapter == null ? false : true); clientData.put("havewifi", CommonUtil.isWiFiActive(context)); clientData.put("havegps", locationManager == null ? false : true); clientData.put("havegravity", CommonUtil.isHaveGravity(context));// LatitudeAndLongitude coordinates = CommonUtil.getLatitudeAndLongitude(context, UmsAgent.mUseLocationService); clientData.put("latitude", coordinates.latitude); clientData.put("longitude", coordinates.longitude); CommonUtil.printLog("clientData---------->", clientData.toString()); } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return clientData; }
From source file:tw.com.sti.store.api.android.AndroidApiService.java
private AndroidApiService(Context context, Configuration config) { this.config = config; this.apiUrl = new ApiUrl(config); if (Logger.DEBUG) L.d("new ApiService()"); sdkVer = Build.VERSION.SDK;/*from ww w . j a v a 2 s . co m*/ sdkRel = Build.VERSION.RELEASE; try { PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES); storeId = pi.packageName; clientVer = "" + pi.versionCode; } catch (NameNotFoundException e) { } TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); deviceId = tm.getDeviceId() == null ? "0" : tm.getDeviceId(); macAddress = NetworkUtils.getDeviceMacAddress(context); subscriberId = tm.getSubscriberId() == null ? "0" : tm.getSubscriberId(); simSerialNumber = tm.getSimSerialNumber() == null ? "0" : tm.getSimSerialNumber(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); try { Class<Display> cls = Display.class; Method method = cls.getMethod("getRotation"); Object retobj = method.invoke(display); int rotation = Integer.parseInt(retobj.toString()); if (Surface.ROTATION_0 == rotation || Surface.ROTATION_180 == rotation) { wpx = "" + display.getWidth(); hpx = "" + display.getHeight(); } else { wpx = "" + display.getHeight(); hpx = "" + display.getWidth(); } } catch (Exception e) { if (display.getOrientation() == 1) { wpx = "" + display.getHeight(); hpx = "" + display.getWidth(); } else { wpx = "" + display.getWidth(); hpx = "" + display.getHeight(); } } SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); // token = pref.getString(PREF_KEY_TOKEN, ""); // uid = pref.getString(PREF_KEY_UID, ""); // userId = pref.getString(PREF_KEY_USER_ID, ""); appFilter = pref.getInt(PREF_KEY_APP_FILTER, 0); // ipLoginEnable = pref.getBoolean(PREF_KEY_IP_LOGIN_ENABLE, true); // ??SIM? String pref_subscriberId = pref.getString(PREF_KEY_SUBSCRIBER_ID, "0"); String pref_simSerialNumber = pref.getString(PREF_KEY_SIM_SERIAL_NUMBER, "0"); if (!subscriberId.equals(pref_subscriberId) || !simSerialNumber.equals(pref_simSerialNumber)) { if (Logger.DEBUG) L.d("Change SIM card."); cleanCredential(context); } this.getCredential(context); }
From source file:com.sonetel.ui.SipHome.java
private void postStartSipService() { // If we have never set fast settings //DBAdapter db = new DBAdapter(this); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); if (CustomDistribution.showFirstSettingScreen()) { if (!prefProviderWrapper.getPreferenceBooleanValue(PreferencesWrapper.HAS_ALREADY_SETUP, false)) { //ContentValues initialValues = new ContentValues(); for (int i = 1; i <= 52; i++) { //initialValues = AccessNumbers.getContentValues(i); getContentResolver().insert(SipProfile.ACCESS_URI, AccessNumbers.getContentValues(i)); //db1.insert(db.databaseHelper.ACCESS_NUMS_TABLE_NAME, null, initialValues); }//w w w . ja v a2s . c o m } prefProviderWrapper.setPreferenceBooleanValue(prefWrapper.ACCESS_NUM_ALREADY_FETCHED, true);// yuva should be true prefWrapper.setSimId(tm.getSubscriberId()); Location_Finder locFinder = new Location_Finder(getBaseContext()); prefWrapper.setTelCountryCode(locFinder.getTelContryCode()); prefWrapper.setCurrentLocation(tm.getNetworkCountryIso()); //PrefsLogic.setCallthruNumber(getBaseContext()); } else { boolean doFirstParams = !prefProviderWrapper .getPreferenceBooleanValue(PreferencesWrapper.HAS_ALREADY_SETUP, false); prefProviderWrapper.setPreferenceBooleanValue(PreferencesWrapper.HAS_ALREADY_SETUP, true); if (!tm.getSubscriberId().equalsIgnoreCase(prefWrapper.getSimId())) { //final DBAdapter db = new DBAdapter(this); final EditText input = new EditText(this); new AlertDialog.Builder(this) .setTitle("New SIM: Please enter new mobile number") //.setMessage("Please enter your new mobile number in Sign in screen") .setIcon(R.drawable.ic_wizard_sonetel) .setView(input) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String mobile = input.getText().toString(); int nbrOfAccount = doWeHaveAccount(); SipProfile account = new SipProfile(); if (nbrOfAccount != 0) { account = SipProfile.getProfileFromDbId(getActivity(), 1, DBProvider.ACCOUNT_FULL_PROJECTION); account.mobile_nbr = mobile; getContentResolver().update( ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, 1), account.getDbContentValues(), null, null); } TelephonyManager tm = (TelephonyManager) getSystemService( Context.TELEPHONY_SERVICE); prefWrapper.setSimId(tm.getSubscriberId()); if (mobile.length() < 8 && !mobile.startsWith("+")) { Toast.makeText(getBaseContext(), "Invalid mobile number. Please enter +MOBILENUMBER in the international format", Toast.LENGTH_LONG).show(); } } private Context getActivity() { // TODO Auto-generated method stub return null; } }) .show(); } if (doFirstParams) { prefProviderWrapper.resetAllDefaultValues(); } } // If we have no account yet, open account panel, if (!hasTriedOnceActivateAcc && isInternetAvail) { int accountCount = 0; accountCount = doWeHaveAccount(); if (accountCount == 0) { Intent accountIntent = null; WizardInfo distribWizard = CustomDistribution.getCustomDistributionWizard(); if (distribWizard != null) { accountIntent = new Intent(this, BasePrefsWizard.class); accountIntent.putExtra(SipProfile.FIELD_WIZARD, distribWizard.id); } // else { // accountIntent = new Intent(this, AccountsEditList.class); // } if (accountIntent != null) { accountIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(accountIntent); hasTriedOnceActivateAcc = true; return; } } hasTriedOnceActivateAcc = false; } }