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:com.p2p.misc.DeviceUtility.java
public String getIMSINo() { TelephonyManager tManager = (TelephonyManager) mactivity.getSystemService(Context.TELEPHONY_SERVICE); String imsi = tManager.getSubscriberId(); return imsi;/*from w ww . java 2s . com*/ }
From source file:com.xdyou.sanguo.GameSanGuo.java
protected void onCreate(Bundle savedInstanceState) { Log.d("SGAPP", "onCreate"); mActivity = this; super.onCreate(savedInstanceState); //AppsFlyerSDK initial 2015.1.12 AppsFlyerLib.setAppsFlyerKey("6HRzTLQfzQHGBQ87KzZttH"); //? AppsFlyer AppsFlyerLib.sendTracking(getApplicationContext()); //GA sdk ?// www. j a va 2 s . c o m GameAnalytics.initialise(this, GA_SCR_KEY, GA_GAME_KEY); GameAnalytics.startSession(this); //MM: AdvertiserSDK 2014.11.26 Tracker.conversionTrack(this, "zywx_sgyxlm_hk_mo_tw"); //?? getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // ========================?TalkingData Log.d("SGAPP", "talkingdataAppid || " + talkingDataAppId); TalkingDataGA.init(this, talkingDataAppId, talkingDataChannelId); // ========================?TalkingData // ===================Facebook ? // ??session this.createFBSession(); // Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS); // ===================Facebook ? //GoCPA GocpaUtil.setAppId(GOCPA_APPID); GocpaUtil.setAdvertiserId(GOCPA_ADVID); GocpaUtil.setReferral(false); GocpaTracker.getInstance(this).reportDevice(); // ==================Go2Play listener_Begin_======================================= TradeService.setOnBalanceChangedListener(new ICallback() { @Override public void onResult(boolean isSuccess, Bundle bundle, Throwable ths) { // ??? if (isSuccess) { Log.e("go2play", "Charged Success!"); Log.e("go2play", "Balance: " + TradeService.getBalance(false)); } } }); // ==================Go2Play listener_End_========================================= // ==================ChartBoost SDK _Begin_============================================ // ?chartboost this.cb = Chartboost.sharedChartboost(); // chartboostappIdappKey, sdk???? final String appIdCB = "54af952a43150f627b0fbb4a"; final String appSignatureCB = "bea16683ef974c0393cf55c41719ef694ae8a0d5"; this.cb.onCreate(this, appIdCB, appSignatureCB, null); // ==================ChartBoost SDK_End_============================================== // ==================hasoffers _Begin_============================================ MobileAppTracker.init(getApplicationContext(), "24078", "3fba6dcf91bc7251866e59278574f16a"); mobileAppTracker = MobileAppTracker.getInstance(); // Collect Google Play Advertising ID new Thread(new Runnable() { @Override public void run() { try { Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()); mobileAppTracker.setGoogleAdvertisingId(adInfo.getId(), adInfo.isLimitAdTrackingEnabled()); } catch (IOException e) { } catch (GooglePlayServicesNotAvailableException e) { mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID)); } catch (GooglePlayServicesRepairableException e) { // Encountered a recoverable error connecting to Google Play // services. } } }).start(); // For collecting Android ID, device ID, and MAC address // Before August 1st 2014, remove these calls - only Google AID should // be collected. mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID)); String deviceId = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); mobileAppTracker.setDeviceId(deviceId); try { WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); mobileAppTracker.setMacAddress(wm.getConnectionInfo().getMacAddress()); } catch (NullPointerException e) { System.out.println("NullPointerExp"); } // ==================hasoffers _End_=========================== // ?? ?Handler????????facebook? handler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case FB_LOGIN: fbLogin(); break; case FB_LOGOUT: fbLogout(); break; case FB_SHARE: { // ????????? String imageName = msg.obj.toString(); fbShareContent(imageName); } break; case FB_CREATE_SESSION: { createFBSession(); } break; case GOTO_GOOGLE_PLAY: { enterGooglePlay(); } break; case BUID_DIALOG: { buildDialog(); } break; case HANDLER_OPEN_URL: { execOpenUrl((String) msg.obj); } break; case APP_FLYERS_LOGIN: { appFlyersTrackerLogin((String) msg.obj); } break; case MSG_SHOW_TOAST: { handleShowToast((String) msg.obj); } break; case MSG_SET_USER_DATA: { handleSetUserData((SgUserData) msg.obj); } break; default: Log.e("facebook", "error come out!"); System.out.println("oh shit!"); break; } } }; }
From source file:com.andybotting.tubechaser.activity.Home.java
/** * Upload statistics to remote server/*from w w w . java 2 s . c om*/ */ private void uploadStats() { if (LOGV) Log.v(TAG, "Sending statistics"); // gather all of the device info String app_version = ""; try { try { PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); app_version = pi.versionName; } catch (NameNotFoundException e) { app_version = "N/A"; } TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String device_uuid = tm.getDeviceId(); String device_id = "00000000000000000000000000000000"; if (device_uuid != null) { device_id = GenericUtil.MD5(device_uuid); } String mobile_country_code = tm.getNetworkCountryIso(); String mobile_network_number = tm.getNetworkOperator(); int network_type = tm.getNetworkType(); // get the network type string String mobile_network_type = "N/A"; switch (network_type) { case 0: mobile_network_type = "TYPE_UNKNOWN"; break; case 1: mobile_network_type = "GPRS"; break; case 2: mobile_network_type = "EDGE"; break; case 3: mobile_network_type = "UMTS"; break; case 4: mobile_network_type = "CDMA"; break; case 5: mobile_network_type = "EVDO_0"; break; case 6: mobile_network_type = "EVDO_A"; break; case 7: mobile_network_type = "1xRTT"; break; case 8: mobile_network_type = "HSDPA"; break; case 9: mobile_network_type = "HSUPA"; break; case 10: mobile_network_type = "HSPA"; break; } String device_version = android.os.Build.VERSION.RELEASE; if (device_version == null) { device_version = "N/A"; } String device_model = android.os.Build.MODEL; if (device_model == null) { device_model = "N/A"; } String device_language = getResources().getConfiguration().locale.getLanguage(); String home_function = mPreferenceHelper.defaultLaunchActivity(); // post the data HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://tubechaser.andybotting.com/stats/app/send"); post.setHeader("Content-Type", "application/x-www-form-urlencoded"); List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("device_id", device_id)); pairs.add(new BasicNameValuePair("app_version", app_version)); pairs.add(new BasicNameValuePair("home_function", home_function)); pairs.add(new BasicNameValuePair("device_model", device_model)); pairs.add(new BasicNameValuePair("device_version", device_version)); pairs.add(new BasicNameValuePair("device_language", device_language)); pairs.add(new BasicNameValuePair("mobile_country_code", mobile_country_code)); pairs.add(new BasicNameValuePair("mobile_network_number", mobile_network_number)); pairs.add(new BasicNameValuePair("mobile_network_type", mobile_network_type)); try { post.setEntity(new UrlEncodedFormEntity(pairs)); } catch (UnsupportedEncodingException e) { // Do nothing } try { HttpResponse response = client.execute(post); response.getStatusLine().getStatusCode(); } catch (Exception e) { if (LOGV) Log.v(TAG, "Error uploading stats: " + e.getMessage()); } } catch (Exception e) { // Do nothing } }
From source file:com.samknows.measurement.AppSettings.java
public Map<String, String> getJSONExtra() { Map<String, String> ret = new HashMap<String, String>(); if (!anonymous) { ret.put(JSON_UNIT_ID, getUnitId()); }/*from w ww.j av a2s. c o m*/ ret.put(JSON_APP_VERSION_NAME, app_version_name); ret.put(JSON_APP_VERSION_CODE, app_version_code); ScheduleConfig config = CachingStorage.getInstance().loadScheduleConfig(); if (config != null) { ret.put(JSON_SCHEDULE_CONFIG_VERSION, config.version); } else { ret.put(JSON_SCHEDULE_CONFIG_VERSION, "no_schedule_config"); } long time = System.currentTimeMillis(); ret.put(JSON_TIMESTAMP, (time / 1000) + ""); ret.put(JSON_DATETIME, new java.util.Date(time).toString()); ret.put(JSON_TIMEZONE, TimeUtils.millisToHours(TimeZone.getDefault().getRawOffset()) + ""); if (enterprise_id != null) { ret.put(JSON_ENTERPRISE_ID, enterprise_id); } String user_self_id = PreferenceManager.getDefaultSharedPreferences(ctx) .getString(Constants.PREF_USER_SELF_ID, null); if (user_self_id != null) { ret.put(JSON_USER_SELF_ID, user_self_id); } TelephonyManager manager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); String simOperatorCode = ""; if (manager != null) { simOperatorCode = manager.getSimOperator(); } ret.put(JSON_SIMOPERATORCODE, simOperatorCode); return ret; }
From source file:com.hybris.mobile.Hybris.java
public void setUuid(Context context) { final String uuid = Hybris.getSharedPreferenceString(InternalConstants.KEY_PREF_UUID); UUID unique_uid;//from w w w .j av a2 s .c o m if (uuid.isEmpty()) { final String id = Hybris.getSharedPreferenceString(InternalConstants.KEY_PREF_DEVICE_ID); if (!id.isEmpty()) { // Use the ids previously computed and stored in the prefs file try { unique_uid = UUID.nameUUIDFromBytes(id.getBytes("utf8")); } catch (UnsupportedEncodingException e) { LoggingUtils.e(LOG_TAG, "Error creating UUID " + e.getLocalizedMessage(), getAppContext()); throw new RuntimeException(e); } } else { try { final String deviceId = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)) .getDeviceId(); unique_uid = deviceId != null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")) : UUID.randomUUID(); } catch (UnsupportedEncodingException e) { LoggingUtils.e(LOG_TAG, "Error creating UUID " + e.getLocalizedMessage(), getAppContext()); throw new RuntimeException(e); } } // Write the value out to the prefs file Hybris.setSharedPreferenceString(InternalConstants.KEY_PREF_UUID, unique_uid.toString()); } }
From source file:com.mobicage.rogerthat.registration.AbstractRegistrationActivity.java
public void registerDevice() { T.UI();//www . j a va2s . c o m final HttpClient httpClient = HTTPUtil.getHttpClient(); final String email = mWizard.getEmail(); final String tosAge = mWizard.getTOSAge(); final String pushNotifcationsEnabled = mWizard.getPushNotificationEnabled(); final String timestamp = "" + mWizard.getTimestamp(); final String deviceId = mWizard.getDeviceId(); final String registrationId = mWizard.getRegistrationId(); // Make call to Rogerthat String message = getString(R.string.activating); final ProgressDialog progressDialog = UIUtils.showProgressDialog(mActivity, null, message, true, false); final SafeRunnable showErrorDialog = new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); progressDialog.dismiss(); UIUtils.showErrorPleaseRetryDialog(mActivity); } }; runOnWorker(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.REGISTRATION(); String version = "3"; String signature = SecurityUtils.sha256(version + " " + email + " " + timestamp + " " + deviceId + " " + registrationId + " " + CloudConstants.REGISTRATION_MAIN_SIGNATURE); HttpPost httppost = HTTPUtil.getHttpPost(mActivity, CloudConstants.REGISTRATION_REGISTER_DEVICE_URL); try { List<NameValuePair> nameValuePairs = HTTPUtil.getRegistrationFormParams(mActivity); nameValuePairs.add(new BasicNameValuePair("version", version)); nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp)); nameValuePairs.add(new BasicNameValuePair("device_id", deviceId)); nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId)); nameValuePairs.add(new BasicNameValuePair("signature", signature)); nameValuePairs.add(new BasicNameValuePair("email", email)); nameValuePairs.add(new BasicNameValuePair("tos_age", tosAge)); nameValuePairs .add(new BasicNameValuePair("push_notifications_enabled", pushNotifcationsEnabled)); nameValuePairs.add(new BasicNameValuePair("GCM_registration_id", getGCMRegistrationId())); nameValuePairs.add(new BasicNameValuePair("hardware_model", SystemPlugin.getDeviceModelName())); TelephonyManager telephonyManager = (TelephonyManager) mService .getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager != null) { nameValuePairs.add( new BasicNameValuePair("sim_carrier_name", telephonyManager.getSimOperatorName())); } httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = httpClient.execute(httppost); int statusCode = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (entity == null) { runOnUI(showErrorDialog); return; } @SuppressWarnings("unchecked") final Map<String, Object> responseMap = (Map<String, Object>) JSONValue .parse(new InputStreamReader(entity.getContent())); if (statusCode != 200 || responseMap == null) { if (statusCode == 500 && responseMap != null) { final String errorMessage = (String) responseMap.get("error"); if (errorMessage != null) { runOnUI(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); progressDialog.dismiss(); UIUtils.showDialog(mActivity, null, errorMessage); } }); return; } } runOnUI(showErrorDialog); return; } JSONObject account = (JSONObject) responseMap.get("account"); setAgeAndGenderSet((Boolean) responseMap.get("age_and_gender_set")); final RegistrationInfo info = new RegistrationInfo(email, new Credentials((String) account.get("account"), (String) account.get("password"))); runOnUI(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); mWizard.setEmail(email); mWizard.save(); tryConnect(progressDialog, 1, getString(R.string.registration_establish_connection, email, getString(R.string.app_name)) + " ", info); } }); } catch (Exception e) { L.d(e); runOnUI(showErrorDialog); } } }); }
From source file:com.roamprocess1.roaming4world.syncadapter.SyncAdapter.java
public String GetCountryZipCode() { String CountryID = ""; String CountryZipCode = ""; TelephonyManager manager = (TelephonyManager) mcontext.getSystemService(Context.TELEPHONY_SERVICE); // getNetworkCountryIso CountryID = manager.getSimCountryIso().toUpperCase(); String[] rl = mcontext.getResources().getStringArray(R.array.CountryCodes); for (int i = 0; i < rl.length; i++) { String[] g = rl[i].split(","); if (g[1].trim().equals(CountryID.trim())) { CountryZipCode = g[0];/* w w w .j a va2s . c o m*/ break; } } return CountryZipCode; }
From source file:com.p2p.misc.DeviceUtility.java
public int getSignalStrength() { telephonyManager = (TelephonyManager) mactivity.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(Listener, Listener.LISTEN_SIGNAL_STRENGTHS); System.out.println("returning per_value = " + signal_value); return signal_value; }
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 w w w. java2s.co m } return deviceId; }