List of usage examples for android.telephony TelephonyManager getDeviceId
@Deprecated
@SuppressAutoDoc
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getDeviceId()
From source file:com.lewa.crazychapter11.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //set to full screen // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ///set to no title // requestWindowFeature(Window.FEATURE_NO_TITLE); // acionBar = getSupportActionBar(); // acionBar = getActionBar(); // acionBar.hide(); // Window win = getWindow(); // win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // win.setStatusBarColor(Color.TRANSPARENT); // win.setNavigationBarColor(Color.TRANSPARENT); /*//* w ww.j av a 2s . c o m*/ win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); win.setStatusBarColor(Color.TRANSPARENT); win.setNavigationBarColor(Color.TRANSPARENT); //*/ super.onCreate(savedInstanceState); setContentView(R.layout.main); /* setTheme(R.style.CrazyTheme); */ AddGameBtn(); AddNoification(); LookupContact(); AddServiceBtn(); broadcastMain(); mediaPlayerMain(); mediaRecordSoundMain(); cameraMain(); recordvideoMain(); queMySql(); TestFragment(); justForTest(); LoadJson(); AddTestBtn(); AddUsageStatsBtn(); AddPeopleProvideBtn(); getInput(); ////just for test shutdown broadcast receiver IntentFilter mIntentFilter = new IntentFilter("android.intent.action.ACTION_SHUTDOWN"); mIntentFilter.addAction("com.lewa.alarm.test"); mIntentFilter.addAction("android.provider.Telephony.SECRET_CODE"); mIntentFilter.addAction("android.intent.action.SCREEN_ON"); mIntentFilter.addAction("android.intent.action.SCREEN_OFF"); mShoutdown = new shutdownReceiver(); registerReceiver(mShoutdown, mIntentFilter); ////test preferences = getSharedPreferences("crazyit", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editor = preferences.edit(); preferencestime = getSharedPreferences("RMS_Shutdown_time", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editortime = preferencestime.edit(); SharedShutdownTimeRead(); AddSharedPreBtn(); etNum = (EditText) findViewById(R.id.etNum); // // int maxLength = 4; InputFilter[] fArray = new InputFilter[1]; fArray[0] = new InputFilter.LengthFilter(maxLength); etNum.setFilters(fArray); // // calThread = new CalThread(); calThread.start(); Log.i("algerheMain", "MainActivity onCreate in!!"); String page = getString(R.string.str_page, "345", "24"); Log.i("algerheMain", "page=" + page); // /just for test here ComponentName comp = getIntent().getComponent(); show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText( "??" + comp.getPackageName() + " \n ??" + comp.getClassName()); ////MD5 check item ///1.IMEI TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); String szImei = TelephonyMgr.getDeviceId(); String m_szSIMSerialNm = TelephonyMgr.getSimSerialNumber(); CellLocation m_location = TelephonyMgr.getCellLocation(); String m_Line1Number = TelephonyMgr.getLine1Number(); String m_OperatorName = TelephonyMgr.getSimOperatorName(); Log.i("algerheTelephonyMgr", "szImei=" + szImei); Log.i("algerheTelephonyMgr", "m_szSIMSerialNm=" + m_szSIMSerialNm); Log.i("algerheTelephonyMgr", "m_location=" + m_location); Log.i("algerheTelephonyMgr", "m_Line1Number=" + m_Line1Number); Log.i("algerheTelephonyMgr", "m_OperatorName=" + m_OperatorName); Log.i("algerheMain01", "szImei=" + szImei); Log.i("algerheMain01", "m_szSIMSerialNm=" + m_szSIMSerialNm); ///2.Pseudo-Unique ID String m_szDevIDShort = "35" + //we make this look like a valid IMEI Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 digits Log.i("algerheMain01", "m_szDevIDShort=" + m_szDevIDShort); ///3. Android ID String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.i("algerheMain01", "m_szAndroidID=" + m_szAndroidID); ///4.WLAN MAC Address string WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); String m_szWLANMAC = "unknow_wifi_mac"; if (wm != null && wm.getConnectionInfo() != null) { m_szWLANMAC = wm.getConnectionInfo().getMacAddress(); } Log.i("algerheMain01", "m_szWLANMAC=" + m_szWLANMAC); ///5.BT MAC Address string BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String m_szBTMAC = m_BluetoothAdapter.getAddress(); Log.i("algerheMain01", "m_szBTMAC=" + m_szBTMAC); ///6.sim serial number .getSimSerialNumber() // / ///reflect test checkMethod(); // */ final Intent alarmIntent = new Intent(); Log.i("algerheMain00", "isLewaRom=" + isLewaRom(this, alarmIntent)); handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0x4567) { String languageStr = null; String countryStr = null; Locale[] locList = Locale.getAvailableLocales(); for (int i = 0; i < locList.length; i++) { languageStr += locList[i].getLanguage(); countryStr += locList[i].getCountry(); } // show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText("" + languageStr + " \n " + countryStr); } else if (msg.what == 0x2789) { Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis() + "\n action=" + alarmIntent.getAction()); // sendBroadcast(alarmIntent); } } }; // String strApkPath = intent.getStringExtra("apkPath"); // String strCmd = "pm install -r " + strApkPath; // try { // Process install = Runtime.getRuntime().exec(strCmd); // Log.d(TAG, "install = " + install + ", strCmd =" + strCmd); // }catch (Exception ex){ // Log.d(TAG, ex.getMessage()); // } // */ }
From source file:org.wso2.iot.agent.services.DeviceInfoPayload.java
/** * Fetch all device runtime information. * * @throws AndroidAgentException on error *//*from w w w.j av a2 s. co m*/ @SuppressLint("HardwareIds") private void getInfo() throws AndroidAgentException { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (!CommonUtils.isServiceRunning(context, NetworkInfoService.class)) { Intent serviceIntent = new Intent(context, NetworkInfoService.class); context.startService(serviceIntent); } Location deviceLocation = CommonUtils.getLocation(context); if (device == null) { device = new Device(); } deviceInfo = new DeviceInfo(context); Power power = phoneState.getBatteryDetails(); device.setDeviceIdentifier(deviceInfo.getDeviceId()); device.setDescription(deviceInfo.getDeviceName()); device.setName(deviceInfo.getDeviceName()); List<Device.Property> properties = new ArrayList<>(); Device.Property property = new Device.Property(); property.setName(Constants.Device.SERIAL); property.setValue(deviceInfo.getDeviceSerialNumber()); properties.add(property); if (telephonyManager != null && ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { property = new Device.Property(); property.setName(Constants.Device.IMEI); property.setValue(telephonyManager.getDeviceId()); properties.add(property); } property = new Device.Property(); property.setName(Constants.Device.IMSI); property.setValue(deviceInfo.getIMSINumber()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.MAC); property.setValue(deviceInfo.getMACAddress()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.MODEL); property.setValue(deviceInfo.getDeviceModel()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.VENDOR); property.setValue(deviceInfo.getDeviceManufacturer()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.OS); property.setValue(deviceInfo.getOsVersion()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.OS_BUILD_DATE); property.setValue(deviceInfo.getOSBuildDate()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.NAME); property.setValue(deviceInfo.getDeviceName()); properties.add(property); if (deviceLocation != null) { double latitude = deviceLocation.getLatitude(); double longitude = deviceLocation.getLongitude(); if (latitude != 0 && longitude != 0) { property = new Device.Property(); property.setName(Constants.Device.MOBILE_DEVICE_LATITUDE); property.setValue(String.valueOf(latitude)); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.MOBILE_DEVICE_LONGITUDE); property.setValue(String.valueOf(longitude)); properties.add(property); } } if (registrationId != null) { property = new Device.Property(); property.setName(Constants.Device.FCM_TOKEN); property.setValue(registrationId); properties.add(property); } List<Device.Property> deviceInfoProperties = new ArrayList<>(); property = new Device.Property(); property.setName(Constants.Device.ENCRYPTION_STATUS); property.setValue(String.valueOf(deviceInfo.isEncryptionEnabled())); deviceInfoProperties.add(property); if ((deviceInfo.getSdkVersion() >= Build.VERSION_CODES.LOLLIPOP)) { property = new Device.Property(); property.setName(Constants.Device.PASSCODE_STATUS); property.setValue(String.valueOf(deviceInfo.isPasscodeEnabled())); deviceInfoProperties.add(property); } property = new Device.Property(); property.setName(Constants.Device.BATTERY_LEVEL); int batteryLevel = Math.round(power.getLevel()); property.setValue(String.valueOf(batteryLevel)); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_INTERNAL_TOTAL); property.setValue(String.valueOf(phoneState.getTotalInternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_INTERNAL_AVAILABLE); property.setValue(String.valueOf(phoneState.getAvailableInternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_EXTERNAL_TOTAL); property.setValue(String.valueOf(phoneState.getTotalExternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_EXTERNAL_AVAILABLE); property.setValue(String.valueOf(phoneState.getAvailableExternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.NETWORK_OPERATOR); property.setValue(String.valueOf(deviceInfo.getNetworkOperatorName())); deviceInfoProperties.add(property); if (telephonyManager != null && ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { String mPhoneNumber = telephonyManager.getLine1Number(); if (mPhoneNumber != null) { property = new Device.Property(); property.setName(Constants.Device.PHONE_NUMBER); property.setValue(mPhoneNumber); deviceInfoProperties.add(property); } } try { String network = NetworkInfoService.getNetworkStatus(); if (network != null) { property = new Device.Property(); property.setName(Constants.Device.NETWORK_INFO); property.setValue(network); properties.add(property); } if (Constants.WIFI_SCANNING_ENABLED) { // adding wifi scan results.. property = new Device.Property(); property.setName(Constants.Device.WIFI_SCAN_RESULT); property.setValue(NetworkInfoService.getWifiScanResult()); properties.add(property); } } catch (AndroidAgentException e) { Log.e(TAG, "Error retrieving network status. " + e.getMessage()); } RuntimeInfo runtimeInfo = new RuntimeInfo(context); String cpuInfoPayload; try { cpuInfoPayload = mapper.writeValueAsString(runtimeInfo.getCPUInfo()); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property CPU info object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.CPU_INFO); property.setValue(cpuInfoPayload); properties.add(property); String ramInfoPayload; try { ramInfoPayload = mapper.writeValueAsString(runtimeInfo.getRAMInfo()); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property RAM info object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.RAM_INFO); property.setValue(ramInfoPayload); properties.add(property); List<Device.Property> batteryProperties = new ArrayList<>(); property = new Device.Property(); property.setName(Constants.Device.BATTERY_LEVEL); property.setValue(String.valueOf(power.getLevel())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.SCALE); property.setValue(String.valueOf(power.getScale())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.BATTERY_VOLTAGE); property.setValue(String.valueOf(power.getVoltage())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.HEALTH); property.setValue(String.valueOf(power.getHealth())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.STATUS); property.setValue(String.valueOf(power.getStatus())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.PLUGGED); property.setValue(String.valueOf(power.getPlugged())); batteryProperties.add(property); String batteryInfoPayload; try { batteryInfoPayload = mapper.writeValueAsString(batteryProperties); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property battery info object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.BATTERY_INFO); property.setValue(batteryInfoPayload); properties.add(property); // building device info json payload String deviceInfoPayload; try { deviceInfoPayload = mapper.writeValueAsString(deviceInfoProperties); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.INFO); property.setValue(deviceInfoPayload); properties.add(property); device.setProperties(properties); }
From source file:com.mcnc.parecis.bizmob.task.Login20Task.java
@Override protected Response doInBackground(Object... arg0) { Response response = new Response(); final Request request = getRequest(); final BaseActivity activity = request.getSrcActivity(); String callback = ""; String legacy_trcode = ""; JSONObject root = null;/*from w w w .j a v a 2 s . c o m*/ JSONObject param = null; JSONObject auth_info = null; JSONObject legacy_message = null; String progressMsg = ""; ConfigurationModel cm = ConfigurationModel.getConfigurationModel(); long start = System.currentTimeMillis(); try { Logger.d(TAG, "doInBackground"); root = (JSONObject) request.getData(); param = root.getJSONObject("param"); // if (param.has("progress_message")) { progressMsg = param.getString("progress_message"); AbstractActivity.PROGRESS_MESSAGE = progressMsg; activity.runOnUiThread(new Runnable() { @Override public void run() { if (activity.getDlg() != null) { activity.getDlg().setMessage(AbstractActivity.PROGRESS_MESSAGE); } } }); } callback = param.getString("callback"); // ?? . //message = param.getJSONObject("message"); auth_info = param.getJSONObject("auth_info"); legacy_trcode = param.getString("legacy_trcode"); legacy_message = param.getJSONObject("legacy_message"); String password = ""; String user_id = ""; password = auth_info.getString("password"); user_id = auth_info.getString("user_id"); JSONObject data = new JSONObject(); JSONObject newParam = new JSONObject(); JSONObject newMassage = new JSONObject(); JSONObject newHeader = new JSONObject(); JSONObject newBody = new JSONObject(); data.put("param", newParam); newParam.put("message", newMassage); newMassage.put("header", newHeader); newMassage.put("body", newBody); newHeader.put("result", true); newHeader.put("error_code", ""); newHeader.put("error_text", ""); newHeader.put("info_text", ""); newHeader.put("message_version", "0.9"); newHeader.put("login_session_id", ""); newHeader.put("trcode", "LOGIN"); newBody.put("password", password); newBody.put("legacy_trcode", legacy_trcode); newBody.put("legacy_message", legacy_message); newBody.put("user_id", user_id); newBody.put("os_type", Def.OS_TYPE_NAME); boolean emulFlag = false; if (android.os.Build.MODEL.contains("sdk")) { emulFlag = true; } TelephonyManager manager = (TelephonyManager) request.getSrcActivity() .getSystemService(Context.TELEPHONY_SERVICE); boolean manual_phone_number = false; String mobilenum = ""; String tempNumber = ""; if (manager != null) { tempNumber = manager.getLine1Number(); if (tempNumber == null) { mobilenum = cm.getStringSharedPreferences("MANUAL_NUMBER"); manual_phone_number = true; } else if (tempNumber.equals("")) { manual_phone_number = true; mobilenum = cm.getStringSharedPreferences("MANUAL_NUMBER"); } else { if (emulFlag == true) { manual_phone_number = true; mobilenum = cm.getStringSharedPreferences("MANUAL_NUMBER"); } else { manual_phone_number = false; mobilenum = tempNumber; } } } else { mobilenum = cm.getStringSharedPreferences("MANUAL_NUMBER"); if (mobilenum.equals(ConfigurationModel.PREFERENCE_NOTFOUND)) { mobilenum = ""; } manual_phone_number = true; } String device_id = ""; if (manager != null) { device_id = manager.getDeviceId(); if (device_id == null) { device_id = Secure.getString(activity.getContentResolver(), Secure.ANDROID_ID); } } else { device_id = Secure.getString(activity.getContentResolver(), Secure.ANDROID_ID); } newBody.put("manual_phone_number", manual_phone_number); newBody.put("device_id", device_id); // emulator flag true ? device? ? if (auth_info.has("emulator_flag")) { newBody.put("emulator_flag", auth_info.getBoolean("emulator_flag")); } else { newBody.put("emulator_flag", emulFlag); } newBody.put("app_key", Def.APPLICTION_NAME); newBody.put("phone_number", mobilenum); request.setData(data); request.setTrCode("LOGIN"); response.setCallback(callback); JSONObject result = sendReq(request); JSONObject header = null; JSONObject body = null; if (result.has("header")) { header = result.getJSONObject("header"); } boolean remote = false; boolean access_limit = false; if (header.getBoolean("result")) { if (result.has("body")) { body = result.getJSONObject("body"); } // License ? Login20Task SUCCESS ? ?? Task ? ??? // License ?? ? String device_type = cm.getStringSharedPreferences("device_type"); Def.LICENSE_NO_VALUE = body.getString("license_no"); Def.USER_TYPE_VALUE = body.getString("user_type"); //ActivationTask? ? ? ?? Def.DEVICE_TYPE_VALUE = device_type; Def.USER_ID_VALUE = user_id; Def.DEVICE_ID_VALUE = device_id; Def.COMPANY_ID_VALUE = body.getString("company_id"); //"attachment_download": true, //"access_limit": false, //"legacy_message": "", //"legacy_trcode": "" // App Tester boolean app_tester = body.getBoolean("app_tester"); boolean app_tester_before = cm.getBooleanSharedPreferences(ConfigurationModel.APP_TESTER); // Update ? ? ? ? ??. if (app_tester != app_tester_before) { String CONTENT_ROOT = ImageUtil.ROOT_PATH + ImageUtil.CONTENT_ROOT + "/"; activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, "?? .", Toast.LENGTH_LONG).show(); } }); File f = new File(CONTENT_ROOT); if (f.exists()) { FileUtils.delete(f); } cm.setBooleanSharedPreferences(ConfigurationModel.APP_TESTER, app_tester); cm.setVersionContentMajor(0); cm.setVersionContentMinor(0); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, MSG_CHANGE_USER_TYPE, Toast.LENGTH_LONG).show(); } }); activity.finish(); return null; } // remote wipe remote = body.getBoolean("remote_wipe"); if (remote) { activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, MSG_REMOTEWPE, Toast.LENGTH_LONG).show(); } }); activity.finish(); return null; } // assess limmit access_limit = body.getBoolean("access_limit"); if (access_limit) { activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, MSG_ACCESS_LIMIIT, Toast.LENGTH_LONG).show(); } }); activity.finish(); return null; } JSONObject reust_legacy_message = body.getJSONObject("legacy_message"); response.setData(reust_legacy_message); } else { Logger.d(TAG, "bizMob result false : " + result); response.setError(false); response.setData(result); } } catch (Exception e) { e.printStackTrace(); Logger.d(TAG, "Send Error : " + e.getMessage()); JSONObject root1 = new JSONObject(); JSONObject header = new JSONObject(); try { root1.put("header", header); header.put("result", false); if (e instanceof HttpResponseException) { // HTTTP header.put("error_code", "HTTP" + ((HttpResponseException) e).getStatusCode()); header.put("error_text", e.getMessage()); } else if (e instanceof HttpHostConnectException) { // Connect header.put("error_code", "NE0001"); header.put("error_text", e.getMessage()); } else if (e instanceof ConnectTimeoutException) { // Connect header.put("error_code", "NE0001"); header.put("error_text", e.getMessage()); } else if (e instanceof SocketTimeoutException) { // Read header.put("error_code", "NE0002"); header.put("error_text", e.getMessage()); } else if (e instanceof IOException) { // ? ? ? header.put("error_code", "NE0003"); header.put("error_text", e.getMessage()); } else if (e instanceof NullPointerException) { header.put("error_code", "CE0001"); // ? ? header.put("error_text", "NullPointerException"); } else { header.put("error_code", "CE0001"); // ? ? header.put("error_text", e.getMessage()); } } catch (JSONException e1) { e1.printStackTrace(); } response.setError(false); response.setData(root1); } finally { // ?? if (progressMsg.length() > 0) { AbstractActivity.PROGRESS_MESSAGE = AbstractActivity.DEFAULT_PROGRESS_MESSAGE; } // ? ?? ? ?. long end = System.currentTimeMillis(); long processTime = end - start; if (processTime < 200 && processTime > 0) { try { Thread.sleep(200 - processTime); } catch (InterruptedException e) { } } } response.setRequest(request); setResponse(response); return response; }
From source file:com.vegnab.vegnab.MainVNActivity.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public void getUniqueDeviceId(Context context) { // this is used to get a unique identifier for the device this app is being run on // it is primarily used to warn the user if the Visit has been downloaded onto // a different device and the Visit is about to be edited; // This simple fn is not entirely robust for various reasons, but it is adequate since // it is rare for Visits to be edited, and even more rare to be downloaded before editing // this ID may be useful in sorting out field work chaos, to tell where the data came from String deviceId;//from w ww . j ava 2 s . c om try { TelephonyManager tMgr = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)); deviceId = tMgr.getDeviceId(); if (deviceId != null) { // won't have this if device is not a phone, and //not always reliable to read even if it is a phone mDeviceIdSource = "Phone"; mUniqueDeviceId = deviceId; return; } else { // try to get the Android ID deviceId = android.os.Build.SERIAL; // generated on first boot, so may change on system reset // only guaranteed available from API 9 and up // since Gingerbread (Android 2.3) android.os.Build.SERIAL must exist on any device that doesn't provide IMEI if (deviceId != null) { // some Froyo 2.2 builds give the same serial number "9774d56d682e549c" for // all, but these are rare and dying out (fixed ~December 2010. // 4.2+, different profiles on the same device may give different IDs mDeviceIdSource = "Android serial number"; mUniqueDeviceId = deviceId; return; } else { // generate a random number mDeviceIdSource = "random UUID"; mUniqueDeviceId = UUID.randomUUID().toString(); return; } } } catch (Exception e) { // generate a random number mDeviceIdSource = "random UUID"; mUniqueDeviceId = UUID.randomUUID().toString(); return; } }
From source file:com.zld.ui.ZldNewActivity.java
private void initImei() { TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); AppInfo.getInstance().setImei(telephonyManager.getDeviceId()); }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
public static String device_getIMEI(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return telephonyManager.getDeviceId(); }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
/** * Prepare submit forms and submit report *//* w ww.ja v a2 s .c o m*/ private void submitReport() { // Save the open311 user saveOpen311User(); // Prepare issue description String description = ((EditText) getActivity().findViewById(R.id.ri_editTextDesc)).getText().toString(); final TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); Open311User open311User; if (!mAnonymousReportingCheckBox.isChecked()) { open311User = getOpen311UserFromUI(); } else { open311User = getOpen311UserFromStrings(); } IssueLocationHelper issueLocationHelper = getIssueLocationHelper(); ServiceRequest.Builder builder = new ServiceRequest.Builder(); builder.setJurisdiction_id(mOpen311.getJurisdiction()).setService_code(mService.getService_code()) .setService_name(mService.getService_name()) .setLatitude(issueLocationHelper.getIssueLocation().getLatitude()) .setLongitude(issueLocationHelper.getIssueLocation().getLongitude()).setSummary(null) .setDescription(description).setEmail(open311User.getEmail()).setFirst_name(open311User.getName()) .setLast_name(open311User.getLastName()).setPhone(open311User.getPhone()) .setAddress_string(getCurrentAddress()).setDevice_id(tm.getDeviceId()); if (mImagePath != null) { attachImage(builder); } ServiceRequest serviceRequest = builder.createServiceRequest(); List<Open311AttributePair> attributes = createOpen311Attributes(mServiceDescription); serviceRequest.setAttributes(attributes); int errorCode = Open311Validator.validateServiceRequest(serviceRequest, mOpen311.getOpen311Option().getOpen311Type(), mServiceDescription); if (Open311Validator.isValid(errorCode)) { // Append transit service parameters to issue description if (ServiceUtils.isTransitServiceByType(mService.getType())) { description += getTransitIssueParameters(mService); serviceRequest.setDescription(description); } // Start progress showProgressDialog(true); mRequestTask = new ServiceRequestTask(mOpen311, serviceRequest, this); mRequestTask.execute(); ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.SUBMIT.toString(), getString(R.string.analytics_action_problem), mService.getService_name()); } else { createToastMessage(Open311Validator.getErrorMessageForServiceRequestByErrorCode(errorCode)); } }
From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java
@Override protected void onStart() { super.onStart(); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); imeicode = tm.getDeviceId(); new httppoststart().execute(); if (flag_isPlayerTransition) { flag_isPlayerTransition = false; resourceType = ""; resourceGooruId = ""; }//www. j av a2 s . com Log.i("onStartSearchRes", "onStart"); }
From source file:mobile.tiis.appv2.base.BackboneApplication.java
public static String getDeviceId(Context ctx) { if (deviceId == null) { TelephonyManager tm = (TelephonyManager) ctx.getApplicationContext() .getSystemService(Context.TELEPHONY_SERVICE); deviceId = tm.getDeviceId(); }//from ww w.ja va2s.c o m return deviceId; }