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.snt.bt.recon.activities.MainActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(com.snt.bt.recon.R.layout.activity_main); ButterKnife.bind(this); logDebug("Activity", "######################## On Create ########################"); //Lock orientation setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //Leave screen on getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //leave cpu on wl = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "wlTag"); wl.acquire();//from ww w. jav a2 s. c o m //For device id telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); //for connectivity cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); try { logDebug("DatabaseTest", "Reading all trips.."); List<Trip> trips = db.getAll(Trip.class); for (Trip trip : trips) { String log = "session id: " + trip.getSessionId() + " imei: " + trip.getImei() + " transport: " + trip.getTransport() + " TS: " + trip.getTimestampStart() + " TE: " + trip.getTimestampEnd() + " upload status: " + trip.getUploadStatus(); logDebug("DatabaseTest", log); } logDebug("DatabaseTest", "Reading all locations.."); List<GPSLocation> locs = db.getAll(GPSLocation.class); for (GPSLocation loc : locs) { String log = "loc id: " + loc.getLocationId() + " sess id: " + loc.getSessionId() + " timestamp: " + loc.getTimestamp() + " upload status: " + loc.getUploadStatus(); logDebug("DatabaseTest", log); } logDebug("DatabaseTest", "Reading all bc.."); List<BluetoothClassicEntry> bcs = db.getAll(BluetoothClassicEntry.class); for (BluetoothClassicEntry bc : bcs) { String log = "sess id: " + bc.getSessionId() + " loc id: " + bc.getLocationId() + " upload status: " + bc.getUploadStatus(); logDebug("DatabaseTest", log); } logDebug("DatabaseTest", "Reading all ble.."); List<BluetoothLowEnergyEntry> bles = db.getAll(BluetoothLowEnergyEntry.class); for (BluetoothLowEnergyEntry ble : bles) { String log = "sess id: " + ble.getSessionId() + " loc id: " + ble.getLocationId() + " upload status: " + ble.getUploadStatus(); logDebug("DatabaseTest", log); } } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } //Show select transpot mode new TransportMode(this).show(); // Show EULA new AppEULA(this).show(); //displayFeedbackDialog(); //avtivity recognition start mActivityRecognitionScan = new ActivityRecognitionUtil(this); mActivityRecognitionScan.startActivityRecognitionScan(); //Filter the Intent and register broadcast receiver registerReceiver(ActivityRecognitionReceiver, new IntentFilter("ImActive")); //gps gpsStatusCheck(); locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationListener = new MyLocationListener(); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 3, locationListener); //bt mBluetoothUtils = new BluetoothUtils(this); //ble mLeDeviceStore = new BluetoothLeDeviceStore(); mLeScanner = new BluetoothLeScanner(mLeScanCallback, mBluetoothUtils); //bc mBcDeviceList = new ArrayList<>(); final Handler h = new Handler(); final int delay = 60000; h.postDelayed(new Runnable() { public void run() { syncServerDatabase(); h.postDelayed(this, delay); } }, delay); //Clean BLE table in case device last timestamp is > 10 seconds final Handler h2 = new Handler(); h2.postDelayed(new Runnable() { public void run() { //clear old ble devices for (BluetoothLeDevice device : mLeDeviceStore.getDeviceList()) { long diff = System.currentTimeMillis() - device.getTimestamp(); if (diff > 10000) { mLeDeviceStore.removeDevice(device); //Refresh the listview final EasyObjectCursor<BluetoothLeDevice> c = mLeDeviceStore.getDeviceCursor(); runOnUiThread(new Runnable() { @Override public void run() { mLeDeviceListAdapter.swapCursor(c); } }); } } h2.postDelayed(this, 1000);//1 sec } }, 1000); }
From source file:com.t2.compassionMeditation.Graphs1Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, this.getClass().getSimpleName() + ".onCreate()"); // We don't want the screen to timeout in this activity getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); this.requestWindowFeature(Window.FEATURE_NO_TITLE); // This needs to happen BEFORE setContentView setContentView(R.layout.graphs_activity_layout); mInstance = this; sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mLoggingEnabled = SharedPref.getBoolean(this, "enable_logging", true); mDatabaseEnabled = SharedPref.getBoolean(this, "database_enabled", false); mAntHrmEnabled = SharedPref.getBoolean(this, "enable_ant_hrm", false); mInternalSensorMonitoring = SharedPref.getBoolean(this, "inernal_sensor_monitoring_enabled", false); if (mAntHrmEnabled) { mHeartRateSource = HEARTRATE_ANT; } else {//from w w w . java 2 s.c om mHeartRateSource = HEARTRATE_ZEPHYR; } // The session start time will be used as session id // Note this also sets session start time // **** This session ID will be prepended to all JSON data stored // in the external database until it's changed (by the start // of a new session. Calendar cal = Calendar.getInstance(); SharedPref.setBioSessionId(sharedPref, cal.getTimeInMillis()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.US); String sessionDate = sdf.format(new Date()); String userId = SharedPref.getString(this, "SelectedUser", ""); long sessionId = SharedPref.getLong(this, "bio_session_start_time", 0); mDataOutHandler = new DataOutHandler(this, userId, sessionDate, mAppId, DataOutHandler.DATA_TYPE_EXTERNAL_SENSOR, sessionId); if (mDatabaseEnabled) { TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); String myNumber = telephonyManager.getLine1Number(); String remoteDatabaseUri = SharedPref.getString(this, "database_sync_name", getString(R.string.database_uri)); // remoteDatabaseUri += myNumber; Log.d(TAG, "Initializing database at " + remoteDatabaseUri); // TODO: remove try { mDataOutHandler.initializeDatabase(dDatabaseName, dDesignDocName, dDesignDocId, byDateViewName, remoteDatabaseUri); } catch (DataOutHandlerException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } mDataOutHandler.setRequiresAuthentication(false); } mBioDataProcessor.initialize(mDataOutHandler); if (mLoggingEnabled) { mDataOutHandler.enableLogging(this); } if (mLogCatEnabled) { mDataOutHandler.enableLogCat(); } // Log the version try { PackageManager packageManager = getPackageManager(); PackageInfo info = packageManager.getPackageInfo(getPackageName(), 0); mApplicationVersion = info.versionName; String versionString = mAppId + " application version: " + mApplicationVersion; DataOutPacket packet = new DataOutPacket(); packet.add(DataOutHandlerTags.version, versionString); try { mDataOutHandler.handleDataOut(packet); } catch (DataOutHandlerException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } } catch (NameNotFoundException e) { Log.e(TAG, e.toString()); } // Set up UI elements Resources resources = this.getResources(); AssetManager assetManager = resources.getAssets(); mPauseButton = (Button) findViewById(R.id.buttonPause); mAddMeasureButton = (Button) findViewById(R.id.buttonAddMeasure); mTextInfoView = (TextView) findViewById(R.id.textViewInfo); mMeasuresDisplayText = (TextView) findViewById(R.id.measuresDisplayText); // Don't actually show skin conductance meter unless we get samples ImageView image = (ImageView) findViewById(R.id.imageView1); image.setImageResource(R.drawable.signal_bars0); // Check to see of there a device configured for EEG, if so then show the skin conductance meter String tmp = SharedPref.getString(this, "EEG", null); if (tmp != null) { image.setVisibility(View.VISIBLE); } else { image.setVisibility(View.INVISIBLE); } // Initialize SPINE by passing the fileName with the configuration properties try { mManager = SPINEFactory.createSPINEManager("SPINETestApp.properties", resources); } catch (InstantiationException e) { Log.e(TAG, "Exception creating SPINE manager: " + e.toString()); e.printStackTrace(); } try { currentMindsetData = new MindsetData(this); } catch (Exception e1) { Log.e(TAG, "Exception creating MindsetData: " + e1.toString()); e1.printStackTrace(); } // Establish nodes for BSPAN // Create a broadcast receiver. Note that this is used ONLY for command messages from the service // All data from the service goes through the mail SPINE mechanism (received(Data data)). // See public void received(Data data) this.mCommandReceiver = new SpineReceiver(this); int itemId = 0; eegPos = itemId; // eeg always comes first mBioParameters.clear(); // First create GraphBioParameters for each of the EEG static params (ie mindset) for (itemId = 0; itemId < MindsetData.NUM_BANDS + 2; itemId++) { // 2 extra, for attention and meditation GraphBioParameter param = new GraphBioParameter(itemId, MindsetData.spectralNames[itemId], "", true); param.isShimmer = false; mBioParameters.add(param); } // Now create all of the potential dynamic GBraphBioParameters (GSR, EMG, ECG, EEG, HR, Skin Temp, Resp Rate // String[] paramNamesStringArray = getResources().getStringArray(R.array.parameter_names); String[] paramNamesStringArray = getResources().getStringArray(R.array.parameter_names_less_eeg); for (String paramName : paramNamesStringArray) { if (paramName.equalsIgnoreCase("not assigned")) continue; GraphBioParameter param = new GraphBioParameter(itemId, paramName, "", true); if (paramName.equalsIgnoreCase("gsr")) { gsrPos = itemId; param.isShimmer = true; param.shimmerSensorConstant = SPINESensorConstants.SHIMMER_GSR_SENSOR; param.shimmerNode = getShimmerNode(); } if (paramName.equalsIgnoreCase("emg")) { emgPos = itemId; param.isShimmer = true; param.shimmerSensorConstant = SPINESensorConstants.SHIMMER_EMG_SENSOR; param.shimmerNode = getShimmerNode(); } if (paramName.equalsIgnoreCase("ecg")) { ecgPos = itemId; param.isShimmer = true; param.shimmerSensorConstant = SPINESensorConstants.SHIMMER_ECG_SENSOR; param.shimmerNode = getShimmerNode(); } if (paramName.equalsIgnoreCase("heart rate")) { heartRatePos = itemId; param.isShimmer = false; } if (paramName.equalsIgnoreCase("resp rate")) { respRatePos = itemId; param.isShimmer = false; } if (paramName.equalsIgnoreCase("skin temp")) { skinTempPos = itemId; param.isShimmer = false; } if (paramName.equalsIgnoreCase("EHealth Airflow")) { eHealthAirFlowPos = itemId; param.isShimmer = false; } if (paramName.equalsIgnoreCase("EHealth Temp")) { eHealthTempPos = itemId; param.isShimmer = false; } if (paramName.equalsIgnoreCase("EHealth SpO2")) { eHealthSpO2Pos = itemId; param.isShimmer = false; } if (paramName.equalsIgnoreCase("EHealth Heartrate")) { eHealthHeartRatePos = itemId; param.isShimmer = false; } if (paramName.equalsIgnoreCase("EHealth GSR")) { eHealthGSRPos = itemId; param.isShimmer = false; } itemId++; mBioParameters.add(param); } // Since These are static nodes (Non-spine) we have to manually put them in the active node list Node mindsetNode = null; mindsetNode = new Node(new Address("" + Constants.RESERVED_ADDRESS_MINDSET)); // Note that the sensor id 0xfff1 (-15) is a reserved id for this particular sensor mManager.getActiveNodes().add(mindsetNode); Node zepherNode = null; zepherNode = new Node(new Address("" + Constants.RESERVED_ADDRESS_ZEPHYR)); mManager.getActiveNodes().add(zepherNode); // The arduino node is programmed to look like a static Spine node // Note that currently we don't have to turn it on or off - it's always streaming // Since Spine (in this case) is a static node we have to manually put it in the active node list // Since the final int RESERVED_ADDRESS_ARDUINO_SPINE = 1; // 0x0001 mSpineNode = new Node(new Address("" + RESERVED_ADDRESS_ARDUINO_SPINE)); mManager.getActiveNodes().add(mSpineNode); final String sessionName; // Check to see if we were requested to play back a previous session try { Bundle bundle = getIntent().getExtras(); if (bundle != null) { sessionName = bundle.getString(BioZenConstants.EXTRA_SESSION_NAME); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Replay Session " + sessionName + "?"); alert.setMessage("Make sure to turn off all Bluetooth Sensors!"); alert.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { try { mDataOutHandler.logNote("Replaying data from session " + sessionName); } catch (DataOutHandlerException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } replaySessionData(sessionName); AlertDialog.Builder alert1 = new AlertDialog.Builder(mInstance); alert1.setTitle("INFO"); alert1.setMessage("Replay of session complete!"); alert1.show(); } }); alert.show(); } } catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } if (mInternalSensorMonitoring) { // IntentSender Launches our service scheduled with with the alarm manager mBigBrotherService = PendingIntent.getService(Graphs1Activity.this, 0, new Intent(Graphs1Activity.this, BigBrotherService.class), 0); long firstTime = SystemClock.elapsedRealtime(); // Schedule the alarm! AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, mPollingPeriod * 1000, mBigBrotherService); // Tell the user about what we did. Toast.makeText(Graphs1Activity.this, R.string.service_scheduled, Toast.LENGTH_LONG).show(); } //testFIRFilter(); // testHR(); }
From source file:com.yozio.android.YozioHelper.java
private void setCarrierMobileAndDeviceInfo() { SharedPreferences settings = context.getSharedPreferences("yozioPreferences", 0); try {/*from ww w . j a va 2s . c o m*/ TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); carrierName = telephonyManager.getNetworkOperatorName(); carrierCountryCode = telephonyManager.getNetworkCountryIso(); if (telephonyManager.getNetworkOperator() != null && (telephonyManager.getNetworkOperator().length() == 5 || telephonyManager.getNetworkOperator().length() == 6)) { mobileCountryCode = telephonyManager.getNetworkOperator().substring(0, 3); mobileNetworkCode = telephonyManager.getNetworkOperator().substring(3); } deviceId = telephonyManager.getDeviceId(); if (!isValidDeviceId(deviceId)) { // Fetch the emulator device ID from the preferences deviceId = settings.getString("emulatorDeviceId", null); } if (!isValidDeviceId(deviceId)) { StringBuffer buff = new StringBuffer(); buff.append("emulator"); String chars = "1234567890abcdefghijklmnopqrstuvw"; int ccLength = chars.length() - 1; for (int i = 0; i < 32; i++) { int index = (int) (Math.random() * ccLength); buff.append(chars.charAt(index)); } SharedPreferences.Editor editor = settings.edit(); editor.putString("emulatorDeviceId", deviceId); editor.commit(); deviceId = buff.toString(); } deviceId = deviceId.toLowerCase(); } catch (Exception e) { deviceId = null; } }
From source file:com.moodmap.SplashScreenActivity.java
private void getDeviceId(Context ctx) { final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice; tmDevice = "" + tm.getDeviceId(); spIDs.edit().putString("DeviceID", tmDevice).commit();// Saves device id // in shared // prefrence }
From source file:com.p2p.misc.DeviceUtility.java
public int simPresent() { TelephonyManager tManager = (TelephonyManager) mactivity.getSystemService(Context.TELEPHONY_SERVICE); int state = TelephonyManager.SIM_STATE_ABSENT; /*//ww w . j a v a 2 s .co m * if (tManager.getSimState() != state) { // sim present } else { // sim * absent } */ return state; }
From source file:com.tapjoy.TapjoyConnectCore.java
/** * Initialize data from the device information and application info. * This data is used in our URL connection to the Tapjoy server. *//*w w w. jav a 2 s . c om*/ private void init() { PackageManager manager = context.getPackageManager(); try { // ANDROID_ID androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); // Get app version. PackageInfo packageInfo = manager.getPackageInfo(context.getPackageName(), 0); appVersion = packageInfo.versionName; // Device platform. Same as device type. deviceType = TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE; platformName = TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE; // Get the device model. deviceModel = android.os.Build.MODEL; deviceManufacturer = android.os.Build.MANUFACTURER; // Get the Android OS Version. deviceOSVersion = android.os.Build.VERSION.RELEASE; // Get the device country and language code. deviceCountryCode = Locale.getDefault().getCountry(); deviceLanguage = Locale.getDefault().getLanguage(); // Tapjoy SDK Library version. libraryVersion = TapjoyConstants.TJC_LIBRARY_VERSION_NUMBER; SharedPreferences settings = context.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0); try { TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager != null) { deviceID = telephonyManager.getDeviceId(); carrierName = telephonyManager.getNetworkOperatorName(); carrierCountryCode = telephonyManager.getNetworkCountryIso(); // getNetworkOperator() returns MCC + MNC, so make sure it's 5 or 6 digits total. // MCC is 3 digits // MNC is 2 or 3 digits if (telephonyManager.getNetworkOperator() != null && (telephonyManager.getNetworkOperator().length() == 5 || telephonyManager.getNetworkOperator().length() == 6)) { mobileCountryCode = telephonyManager.getNetworkOperator().substring(0, 3); mobileNetworkCode = telephonyManager.getNetworkOperator().substring(3); } } TapjoyLog.i(TAPJOY_CONNECT, "deviceID: " + deviceID); boolean invalidDeviceID = false; //---------------------------------------- // Is the device ID null or empty? //---------------------------------------- if (deviceID == null) { TapjoyLog.e(TAPJOY_CONNECT, "Device id is null."); invalidDeviceID = true; } else //---------------------------------------- // Is this an emulator device ID? //---------------------------------------- if (deviceID.length() == 0 || deviceID.equals("000000000000000") || deviceID.equals("0")) { TapjoyLog.e(TAPJOY_CONNECT, "Device id is empty or an emulator."); invalidDeviceID = true; } //---------------------------------------- // Valid device ID. //---------------------------------------- else { // Lower case the device ID. deviceID = deviceID.toLowerCase(); } TapjoyLog.i(TAPJOY_CONNECT, "ANDROID SDK VERSION: " + android.os.Build.VERSION.SDK); // Is this at least Android 2.3+? // Then let's get the serial. if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 9) { TapjoyLog.i(TAPJOY_CONNECT, "TRYING TO GET SERIAL OF 2.3+ DEVICE..."); // THIS CLASS IS ONLY LOADED FOR ANDROID 2.3+ TapjoyHardwareUtil hardware = new TapjoyHardwareUtil(); serialID = hardware.getSerial(); // Is there no IMEI or MEID? if (invalidDeviceID) { deviceID = serialID; } TapjoyLog.i(TAPJOY_CONNECT, "===================="); TapjoyLog.i(TAPJOY_CONNECT, "SERIAL: deviceID: [" + deviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "===================="); //---------------------------------------- // Is the device ID null or empty? //---------------------------------------- if (deviceID == null) { TapjoyLog.e(TAPJOY_CONNECT, "SERIAL: Device id is null."); invalidDeviceID = true; } else //---------------------------------------- // Is this an emulator device ID? //---------------------------------------- if (deviceID.length() == 0 || deviceID.equals("000000000000000") || deviceID.equals("0") || deviceID.equals("unknown")) { TapjoyLog.e(TAPJOY_CONNECT, "SERIAL: Device id is empty or an emulator."); invalidDeviceID = true; } //---------------------------------------- // Valid device ID. //---------------------------------------- else { // Lower case the device ID. deviceID = deviceID.toLowerCase(); invalidDeviceID = false; } } // Is the device ID invalid? This is probably an emulator or pre-production device. if (invalidDeviceID) { StringBuffer buff = new StringBuffer(); buff.append("EMULATOR"); String deviceId = settings.getString(TapjoyConstants.PREF_EMULATOR_DEVICE_ID, null); // Do we already have an emulator device id stored for this device? if (deviceId != null && !deviceId.equals("")) { deviceID = deviceId; } // Otherwise generate a deviceID for emulator testing. else { String constantChars = "1234567890abcdefghijklmnopqrstuvw"; for (int i = 0; i < 32; i++) { int randomChar = (int) (Math.random() * 100); int ch = randomChar % 30; buff.append(constantChars.charAt(ch)); } deviceID = buff.toString().toLowerCase(); // Save the emulator device ID in the prefs so we can reuse it. SharedPreferences.Editor editor = settings.edit(); editor.putString(TapjoyConstants.PREF_EMULATOR_DEVICE_ID, deviceID); editor.commit(); } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting deviceID. e: " + e.toString()); deviceID = null; } // Set the userID to the deviceID as the initial value. if (userID.length() == 0) userID = deviceID; // Save the SHA-2 hash of the device id. sha2DeviceID = TapjoyUtil.SHA256(deviceID); // Get screen density, dimensions and layout. try { // This is a backwards compatibility fix for Android 1.5 which has no display metric API. // If this is 1.6 or higher, then load the class, otherwise the class never loads and // no crash occurs. if (Integer.parseInt(android.os.Build.VERSION.SDK) > 3) { TapjoyDisplayMetricsUtil displayMetricsUtil = new TapjoyDisplayMetricsUtil(context); deviceScreenDensity = "" + displayMetricsUtil.getScreenDensity(); deviceScreenLayoutSize = "" + displayMetricsUtil.getScreenLayoutSize(); } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting screen density/dimensions/layout: " + e.toString()); } // Get mac address. try { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiManager != null) { WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { macAddress = wifiInfo.getMacAddress(); if (macAddress != null && macAddress.length() > 0) { macAddress = macAddress.toUpperCase(); sha1MacAddress = TapjoyUtil.SHA1(macAddress); } } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting device mac address: " + e.toString()); } // Alternate market. if (getFlagValue(TapjoyConnectFlag.ALTERNATE_MARKET) != null) { marketName = getFlagValue(TapjoyConnectFlag.ALTERNATE_MARKET); // Check for existing/supported market names. ArrayList<String> supportedMarketNames = new ArrayList<String>(); supportedMarketNames.add(TapjoyConnectFlag.MARKET_GFAN); // Warning for undefined market names. if (!supportedMarketNames.contains(marketName)) { Log.w(TAPJOY_CONNECT, "Warning -- undefined ALTERNATE_MARKET: " + marketName); } } // Get the referral URL String tempReferralURL = settings.getString(TapjoyConstants.PREF_REFERRAL_URL, null); if (tempReferralURL != null && !tempReferralURL.equals("")) referralURL = tempReferralURL; // Get the client package name. clientPackage = context.getPackageName(); TapjoyLog.i(TAPJOY_CONNECT, "Metadata successfully loaded"); TapjoyLog.i(TAPJOY_CONNECT, "APP_ID = [" + appID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "ANDROID_ID: [" + androidID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "CLIENT_PACKAGE = [" + clientPackage + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceID: [" + deviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "sha2DeviceID: [" + sha2DeviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_SERIAL_ID + ": [" + serialID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_MAC_ADDRESS + ": [" + macAddress + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_SHA1_MAC_ADDRESS + ": [" + sha1MacAddress + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceName: [" + deviceModel + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceManufacturer: [" + deviceManufacturer + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceType: [" + deviceType + "]"); TapjoyLog.i(TAPJOY_CONNECT, "libraryVersion: [" + libraryVersion + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceOSVersion: [" + deviceOSVersion + "]"); TapjoyLog.i(TAPJOY_CONNECT, "COUNTRY_CODE: [" + deviceCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "LANGUAGE_CODE: [" + deviceLanguage + "]"); TapjoyLog.i(TAPJOY_CONNECT, "density: [" + deviceScreenDensity + "]"); TapjoyLog.i(TAPJOY_CONNECT, "screen_layout: [" + deviceScreenLayoutSize + "]"); TapjoyLog.i(TAPJOY_CONNECT, "carrier_name: [" + carrierName + "]"); TapjoyLog.i(TAPJOY_CONNECT, "carrier_country_code: [" + carrierCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MOBILE_COUNTRY_CODE + ": [" + mobileCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MOBILE_NETWORK_CODE + ": [" + mobileNetworkCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MARKET_NAME + ": [" + marketName + "]"); TapjoyLog.i(TAPJOY_CONNECT, "referralURL: [" + referralURL + "]"); if (connectFlags != null) { TapjoyLog.i(TAPJOY_CONNECT, "Connect Flags:"); TapjoyLog.i(TAPJOY_CONNECT, "--------------------"); Set<Entry<String, String>> entries = connectFlags.entrySet(); Iterator<Entry<String, String>> iterator = entries.iterator(); while (iterator.hasNext()) { Entry<String, String> item = iterator.next(); TapjoyLog.i(TAPJOY_CONNECT, "key: " + item.getKey() + ", value: " + Uri.encode(item.getValue())); } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error initializing Tapjoy parameters. e=" + e.toString()); } }
From source file:com.p2p.misc.DeviceUtility.java
public String getIMEINo() { TelephonyManager tManager = (TelephonyManager) mactivity.getSystemService(Context.TELEPHONY_SERVICE); String uid = tManager.getDeviceId(); return uid;//from w w w .j a v a 2s . c o m }
From source file:com.android.server.MaybeService.java
private String getDeviceMEID() { if (mDeviceMEID == null) { TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mDeviceMEID = tm.getDeviceId();/*from www .j a va 2s .co m*/ Log.d(TAG, "Device MEID:" + mDeviceMEID); } return mDeviceMEID; }
From source file:uk.bowdlerize.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_add: { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Get the layout inflater LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_add_url, null); final EditText urlET = (EditText) dialogView.findViewById(R.id.urlET); builder.setView(dialogView)/*from w w w. j av a 2 s . c o m*/ .setPositiveButton(R.string.action_add, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Bundle extras = new Bundle(); Intent receiveURLIntent = new Intent(MainActivity.this, CensorCensusService.class); extras.putString("url", urlET.getText().toString()); extras.putString("hash", MD5(urlET.getText().toString())); extras.putInt("urgency", 0); extras.putBoolean("local", true); //Add our extra info if (getSharedPreferences(MainActivity.class.getSimpleName(), Context.MODE_PRIVATE) .getBoolean("sendISPMeta", true)) { WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiMgr.getConnectionInfo(); TelephonyManager telephonyManager = ((TelephonyManager) getSystemService( Context.TELEPHONY_SERVICE)); if (wifiMgr.isWifiEnabled() && null != wifiInfo.getSSID()) { LocalCache lc = null; Pair<Boolean, String> seenBefore = null; try { lc = new LocalCache(MainActivity.this); lc.open(); seenBefore = lc.findSSID(wifiInfo.getSSID().replaceAll("\"", "")); } catch (Exception e) { e.printStackTrace(); } if (null != lc) lc.close(); if (seenBefore.first) { extras.putString("isp", seenBefore.second); } else { extras.putString("isp", "unknown"); } try { extras.putString("sim", telephonyManager.getSimOperatorName()); } catch (Exception e) { e.printStackTrace(); } } else { try { extras.putString("isp", telephonyManager.getNetworkOperatorName()); } catch (Exception e) { e.printStackTrace(); } try { extras.putString("sim", telephonyManager.getSimOperatorName()); } catch (Exception e) { e.printStackTrace(); } } } receiveURLIntent.putExtras(extras); startService(receiveURLIntent); dialog.cancel(); } }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); return true; } } return super.onOptionsItemSelected(item); }
From source file:com.wbtech.common.CommonUtil.java
/** * ????// w w w . j av a2 s.c o m * @param context * @return WIFI MOBILE */ public static String getNetworkType(Context context) { // ConnectivityManager connectionManager = (ConnectivityManager) // context.getSystemService(Context.CONNECTIVITY_SERVICE); // NetworkInfo networkInfo = connectionManager.getActiveNetworkInfo(); TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int type = manager.getNetworkType(); String typeString = "UNKOWN"; if (type == TelephonyManager.NETWORK_TYPE_CDMA) { typeString = "CDMA"; } if (type == TelephonyManager.NETWORK_TYPE_EDGE) { typeString = "EDGE"; } if (type == TelephonyManager.NETWORK_TYPE_EVDO_0) { typeString = "EVDO_0"; } if (type == TelephonyManager.NETWORK_TYPE_EVDO_A) { typeString = "EVDO_A"; } if (type == TelephonyManager.NETWORK_TYPE_GPRS) { typeString = "GPRS"; } if (type == TelephonyManager.NETWORK_TYPE_HSDPA) { typeString = "HSDPA"; } if (type == TelephonyManager.NETWORK_TYPE_HSPA) { typeString = "HSPA"; } if (type == TelephonyManager.NETWORK_TYPE_HSUPA) { typeString = "HSUPA"; } if (type == TelephonyManager.NETWORK_TYPE_UMTS) { typeString = "UMTS"; } if (type == TelephonyManager.NETWORK_TYPE_UNKNOWN) { typeString = "UNKOWN"; } return typeString; }