List of usage examples for android.content Context WIFI_SERVICE
String WIFI_SERVICE
To view the source code for android.content Context WIFI_SERVICE.
Click Source Link
From source file:com.example.android.mediabrowserservice.Playback.java
public Playback(MusicService service, MusicProvider musicProvider) { this.mService = service; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) service.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "sample_lock"); }
From source file:com.example.android.supportv4.media.Playback.java
public Playback(MediaBrowserServiceSupport service, MusicProvider musicProvider) { this.mService = service; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) service.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "sample_lock"); }
From source file:net.olejon.spotcommander.MyTools.java
public String getCurrentNetwork() { final WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); if (wifiManager.isWifiEnabled()) return wifiManager.getConnectionInfo().getSSID(); return ""; }
From source file:com.google.example.gcmnetworkmanagerquickstart.MainActivity.java
public void startWifiTask() { Log.d(TAG, "startWiFiTask"); // Disable WiFi so the task does not start immediately WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifi.setWifiEnabled(false);/* w ww . ja v a 2 s .c om*/ // [START start_one_off_task] OneoffTask task = new OneoffTask.Builder().setService(MyTaskService.class).setTag(TASK_TAG_WIFI) .setExecutionWindow(0L, 3600L).setRequiredNetwork(Task.NETWORK_STATE_UNMETERED).build(); mGcmNetworkManager.schedule(task); // [END start_one_off_task] }
From source file:com.appdevper.mediaplayer.app.LocalPlayback.java
public LocalPlayback(MusicService service, MusicProvider musicProvider) { this.mService = service; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) service.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "uAmp_lock"); }
From source file:dk.glutter.android.knr.playback.LocalPlayback.java
public LocalPlayback(Context context, MusicProvider musicProvider) { this.mContext = context; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "knr_lock"); this.mState = PlaybackStateCompat.STATE_NONE; }
From source file:io.v.positioning.BluetoothPositionActivity.java
private void addPositionRecord(String deviceName, String deviceAddress, String rssi) { JSONObject data = new JSONObject(); // If user didn't set a device name if (deviceName == null) { deviceName = "name missing"; }/*from ww w .j a v a2 s . c om*/ try { data.put("remoteName", deviceName); data.put("remoteAddress", deviceAddress); data.put("remoteRssi", rssi); String androidId = Settings.Secure.getString(this.getBaseContext().getContentResolver(), Settings.Secure.ANDROID_ID); data.put("androidId", androidId); WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wInfo = wifiManager.getConnectionInfo(); data.put("myMacAddress", wInfo.getMacAddress()); data.put("deviceTime", System.currentTimeMillis()); new ServletPostAsyncTask("bluetooth", data).execute(this); Log.d(TAG, "Added " + androidId); } catch (MalformedURLException e) { Log.e(TAG, "Failed to create ServletPostAsyncTask." + e); } catch (Exception e) { Log.e(TAG, "Failed to add a record to GAE. " + e); } }
From source file:org.wso2.iot.agent.services.NetworkInfoService.java
@Override public void onCreate() { thisInstance = this; if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Creating service"); }//from w w w . j a va 2 s .c o m mapper = new ObjectMapper(); info = getNetworkInfo(); telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(deviceNetworkStatusListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); if (Constants.WIFI_SCANNING_ENABLED) { // Register broadcast receiver // Broadcast receiver will automatically call when number of wifi connections changed registerReceiver(wifiScanReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); // start scanning wifi startWifiScan(); } }
From source file:com.hari.autotasx.GeofenceTransitionsIntentService.java
@Override protected void onHandleIntent(Intent intent) { GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); if (geofencingEvent.hasError()) { String errorMessage = GeofenceErrorMessages.getErrorString(this, geofencingEvent.getErrorCode()); // Log.e(TAG, errorMessage); return;/*ww w. j a va 2 s.co m*/ } int geofenceTransition = geofencingEvent.getGeofenceTransition(); int smsDb = 0; int wifiDb = 0; int silDb = 0; int RemDb = 0; int blueDb = 0; int carDb = 0; String remMsgDb = null; int RemDb_carPark = 0; String remMsgDb_carPark = null; //Creating database object to fetch values ManageDB autodb = new ManageDB(this); autodb.open(); if (!CarParkService.car_flag_static) { Cursor cursor = autodb.getEntry(ActionFragment.geoFence); cursor.moveToFirst(); //System.out.println("cursor count"+cursor.getCount()); //Log.i("logcat",cursor.getString(0)+", "+cursor.getString(1)+" , "+cursor.getString(2)); smsDb = cursor.getInt(5); wifiDb = cursor.getInt(6); silDb = cursor.getInt(7); RemDb = cursor.getInt(8); remMsgDb = cursor.getString(9); blueDb = cursor.getInt(10); carDb = cursor.getInt(11); cursor.close(); } else { Cursor cursor_carpark = autodb.getEntryCarPark(CarParkService.geofence_carpark); cursor_carpark.moveToFirst(); carDb = cursor_carpark.getInt(11); remMsgDb_carPark = cursor_carpark.getString(9); cursor_carpark.close(); } autodb.close(); //Checking Enter/Exit transitions if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) { List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences(); String geofenceTransitionDetails = getGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences); System.out.println("smsdb" + smsDb); if (RemDb == 1) { sendNotification(geofenceTransitionDetails, remMsgDb); } if (carDb == 1) { sendNotification(geofenceTransitionDetails, remMsgDb_carPark); } //Perform actions if set on Actions set if (silDb == 1) { Toast.makeText(this, "silent", Toast.LENGTH_SHORT).show(); AudioManager am = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE); am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); } if (wifiDb == 1) { WifiManager wifiManager = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(true); } if (blueDb == 1) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!mBluetoothAdapter.isEnabled()) { mBluetoothAdapter.enable(); } } if (smsDb == 1) { Toast.makeText(this, "inside sendsms()", Toast.LENGTH_SHORT).show(); SmsManager sm = SmsManager.getDefault(); System.out.printf("sm", sm); sm.sendTextMessage(ActionFragment.smsNo, null, "Hi, I am in " + ActionFragment.geoFence.getNameLoc() + " now!!!!", null, null); } if (carDb == 1) { Intent mapIntent = new Intent(this, CarParkMap.class); mapIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } } else if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences(); String geofenceTransitionDetails = getGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences); if (silDb == 1) { Toast.makeText(this, "general", Toast.LENGTH_SHORT).show(); AudioManager am1 = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE); am1.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } if (wifiDb == 1) { WifiManager wifiManager1 = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); wifiManager1.setWifiEnabled(false); } if (blueDb == 1) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter.isEnabled()) { mBluetoothAdapter.disable(); } } if (smsDb == 1) { Toast.makeText(this, "inside sendsms()", Toast.LENGTH_SHORT).show(); SmsManager sm = SmsManager.getDefault(); System.out.printf("smsNo :" + ActionFragment.smsNo); //fetch sm.sendTextMessage(ActionFragment.smsNo, null, "Hi, I am outside " + ActionFragment.geoFence.getNameLoc() + " now !!!", null, null); } if (RemDb == 1) { sendNotification(geofenceTransitionDetails, remMsgDb); } } }
From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.FixturesFragment.java
/** * Updates the Wifi status//from w ww. j a v a2 s. co m */ private void updateWifiStatusDisplay() { final WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); wifi.setText(Boolean.toString(wifiManager.isWifiEnabled())); }