List of usage examples for android.net.wifi WifiManager SUPPLICANT_CONNECTION_CHANGE_ACTION
String SUPPLICANT_CONNECTION_CHANGE_ACTION
To view the source code for android.net.wifi WifiManager SUPPLICANT_CONNECTION_CHANGE_ACTION.
Click Source Link
From source file:org.peterbaldwin.vlcremote.app.PickServerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PickServerFragment fragment = findOrReplaceFragment(android.R.id.content, TAG, PickServerFragment.class); getActionBar().setDisplayHomeAsUpEnabled(true); mPort = getIntent().getIntExtra(PortSweeper.EXTRA_PORT, 0); if (mPort == 0) { throw new IllegalArgumentException("Port must be specified"); }/*from w ww .j av a 2 s . c om*/ mFile = getIntent().getStringExtra(PortSweeper.EXTRA_FILE); if (mFile == null) { throw new IllegalArgumentException("File must be specified"); } mWorkers = getIntent().getIntExtra(PortSweeper.EXTRA_WORKERS, DEFAULT_WORKERS); mPortSweeper = createPortSweeper(fragment); startSweep(); // Registering the receiver triggers a broadcast with the initial state. // To tell the difference between a broadcast triggered by registering a // receiver and a broadcast triggered by a true network event, note the // time and ignore all broadcasts for one second. mCreateTime = SystemClock.uptimeMillis(); mReceiver = new MyBroadcastReceiver(); // For robustness, update the connection status for all types of events. IntentFilter filter = new IntentFilter(); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); registerReceiver(mReceiver, filter); }
From source file:au.org.intersect.faims.android.ui.activity.ShowModuleActivity.java
private void setupWifiBroadcast() { broadcastReceiver = new WifiBroadcastReceiver(ShowModuleActivity.this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); registerReceiver(broadcastReceiver, intentFilter); ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); // initialize wifi connection state if (mWifi != null && mWifi.isConnected()) { wifiConnected = true;//from w ww. ja v a 2s. c o m } }
From source file:org.metawatch.manager.Monitors.java
private static void createWifiReceiver(final Context context) { if (wifiReceiver != null) return;/*from ww w . j a va 2 s . c o m*/ WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wm.getConnectionInfo(); if (info != null) SignalData.wifiBars = 1 + WifiManager.calculateSignalLevel(info.getRssi(), 4); wifiReceiver = new BroadcastReceiver() { int wifiBars = 0; @Override public void onReceive(Context c, Intent intent) { String action = intent.getAction(); if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) { if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN) != WifiManager.WIFI_STATE_ENABLED) { wifiBars = 0; } } else if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) { if (!intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)) { wifiBars = 0; } } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { NetworkInfo netInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); if (netInfo.getState() != NetworkInfo.State.CONNECTED) { wifiBars = 0; } else { WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); if (wifiInfo == null) { wifiBars = 0; } else { wifiBars = 1 + WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 4); } } } else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) { final int newRssi = intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200); wifiBars = 1 + WifiManager.calculateSignalLevel(newRssi, 4); } if (wifiBars != SignalData.wifiBars) { SignalData.wifiBars = wifiBars; Idle.updateIdle(context, true); } } }; IntentFilter f = new IntentFilter(); f.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); f.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); f.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); f.addAction(WifiManager.RSSI_CHANGED_ACTION); context.registerReceiver(wifiReceiver, f); }
From source file:com.dwdesign.tweetings.activity.HomeActivity.java
@Override public void onStart() { super.onStart(); setSupportProgressBarIndeterminateVisibility(mProgressBarIndeterminateVisible); final IntentFilter filter = new IntentFilter(BROADCAST_REFRESHSTATE_CHANGED); filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); filter.addAction(BROADCAST_NETWORK_STATE_CHANGED); filter.addAction(BROADCAST_TABS_NEW_TWEETS); filter.addAction(BROADCAST_TABS_READ_TWEETS); filter.addAction(BROADCAST_ACCOUNT_LIST_DATABASE_UPDATED); registerReceiver(mStateReceiver, filter); final boolean show_home_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_HOME_TAB, true); final boolean show_mentions_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_MENTIONS_TAB, true); final boolean show_messages_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_MESSAGES_TAB, true); final boolean show_accounts_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_ACCOUNTS_TAB, true); final boolean show_search_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_SEARCH_TAB, true); final boolean show_lists_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_LISTS_TAB, true); final List<TabSpec> tabs = getTabs(this); if (isTabsChanged(tabs) || show_home_tab != mShowHomeTab || show_mentions_tab != mShowMentionsTab || show_messages_tab != mShowMessagesTab || show_accounts_tab != mShowAccountsTab || show_search_tab != mShowSearchTab || show_lists_tab != mShowListsTab) { restart();// w ww .ja va2 s . c om } if (mPreferences.getBoolean(PREFERENCE_KEY_STREAMING_ENABLED, false) == true) { if (mService != null) { try { Twitter twitter = com.dwdesign.tweetings.util.Utils .getDefaultTwitterInstance(getApplicationContext(), true); twitterStream = new TwitterStreamFactory().getInstance(twitter.getAuthorization()); twitterStream.addListener(listener); } catch (final Exception e) { e.printStackTrace(); } } } }
From source file:com.vonglasow.michael.satstat.ui.MainActivity.java
@Override protected void onStart() { super.onStart(); isStopped = false;//from ww w . j a va 2 s . c om registerLocationProviders(); sensorManager.registerListener(this, mOrSensor, iSensorRate); sensorManager.registerListener(this, mAccSensor, iSensorRate); sensorManager.registerListener(this, mGyroSensor, iSensorRate); sensorManager.registerListener(this, mMagSensor, iSensorRate); sensorManager.registerListener(this, mLightSensor, iSensorRate); sensorManager.registerListener(this, mProximitySensor, iSensorRate); sensorManager.registerListener(this, mPressureSensor, iSensorRate); sensorManager.registerListener(this, mHumiditySensor, iSensorRate); sensorManager.registerListener(this, mTempSensor, iSensorRate); if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) registerPhoneStateListener(); else permsRequested[Const.PERM_REQUEST_PHONE_STATE_LISTENER] = true; // register for certain WiFi events indicating that new networks may be in range // An access point scan has completed, and results are available. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); // The state of Wi-Fi connectivity has changed. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION)); // The RSSI (signal strength) has changed. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION)); // A connection to the supplicant has been established or the connection to the supplicant has been lost. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)); permsRequested[Const.PERM_REQUEST_OFFLINE_MAP] = prefMapOffline; /* * Refresh map layers when offline map is selected and we have storage permission * (it might have been granted while we were gone, in which case we wouldn't have the layer) */ if (prefMapOffline && (mapSectionFragment != null) && (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) mapSectionFragment.onMapSourceChanged(); requestPermissions(); }
From source file:com.vonglasow.michael.satstat.MainActivity.java
@Override protected void onResume() { super.onResume(); isStopped = false;//w w w.j ava2 s . c o m registerLocationProviders(this); mLocationManager.addGpsStatusListener(this); mSensorManager.registerListener(this, mOrSensor, iSensorRate); mSensorManager.registerListener(this, mAccSensor, iSensorRate); mSensorManager.registerListener(this, mGyroSensor, iSensorRate); mSensorManager.registerListener(this, mMagSensor, iSensorRate); mSensorManager.registerListener(this, mLightSensor, iSensorRate); mSensorManager.registerListener(this, mProximitySensor, iSensorRate); mSensorManager.registerListener(this, mPressureSensor, iSensorRate); mSensorManager.registerListener(this, mHumiditySensor, iSensorRate); mSensorManager.registerListener(this, mTempSensor, iSensorRate); mTelephonyManager.listen(mPhoneStateListener, (LISTEN_CELL_INFO | LISTEN_CELL_LOCATION | LISTEN_DATA_CONNECTION_STATE | LISTEN_SIGNAL_STRENGTHS)); // register for certain WiFi events indicating that new networks may be in range // An access point scan has completed, and results are available. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); // The state of Wi-Fi connectivity has changed. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION)); // The RSSI (signal strength) has changed. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION)); // A connection to the supplicant has been established or the connection to the supplicant has been lost. registerReceiver(mWifiScanReceiver, new IntentFilter(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)); wifiTimehandler.postDelayed(wifiTimeRunnable, WIFI_REFRESH_DELAY); if ((isMapViewReady) && (mapDownloadLayer != null)) mapDownloadLayer.onResume(); }