Example usage for android.net.wifi WifiManager NETWORK_STATE_CHANGED_ACTION

List of usage examples for android.net.wifi WifiManager NETWORK_STATE_CHANGED_ACTION

Introduction

In this page you can find the example usage for android.net.wifi WifiManager NETWORK_STATE_CHANGED_ACTION.

Prototype

String NETWORK_STATE_CHANGED_ACTION

To view the source code for android.net.wifi WifiManager NETWORK_STATE_CHANGED_ACTION.

Click Source Link

Document

Broadcast intent action indicating that the state of Wi-Fi connectivity has changed.

Usage

From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java

@Override
protected void onResume() {
    super.onResume();
    mBackPressExitCount = 0;//www . j  a  v a  2s. c om
    if (DEBUG) {
        registerReceiver(MPDConnectionHandler.getInstance(),
                new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION));
    }
}

From source file:com.wheelphone.remotemini.WheelphoneRemoteMini.java

public void onResume() {
    if (debugUsbComm) {
        logString = TAG + ": onResume";
        Log.d(TAG, logString);/*from  www. j a  v a2 s .c  o  m*/
        appendLog("debugUsbComm.txt", logString, false);
    }
    super.onResume();

    // when FrontImageActivity is started and the back button is pressed then this "onResume"
    // is called again and we don't want to restart twice the communication. Basically only at the 
    // first call to "onStart" we start the USB communication.       
    if (!frontImageActivityStarted) {
        wheelphone.startUSBCommunication();
    }

    // Determines if user is connected to a wireless network & displays ip 
    if (!streaming)
        displayIpAddress();
    startServers();
    registerReceiver(wifiStateReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION));

    // QCAR-specific resume operation:
    QCAR.onResume();

    // We may start the camera only if the QCAR SDK has already been
    // initialized:
    if (mAppStatus == APPSTATUS_CAMERA_STOPPED) {
        updateApplicationStatus(APPSTATUS_CAMERA_RUNNING);
    }

}

From source file:org.metawatch.manager.Monitors.java

private static void createWifiReceiver(final Context context) {
    if (wifiReceiver != null)
        return;/*from  w w  w  .ja v a2  s  . c  om*/
    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.vonglasow.michael.satstat.ui.MainActivity.java

@Override
protected void onStart() {
    super.onStart();
    isStopped = false;/*from  www . j a  v a  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:org.restcomm.app.qoslib.Services.Intents.IntentHandler.java

public IntentFilter declareIntentFilters() {
    IntentFilter intentFilter = new IntentFilter(IntentHandler.UPDATE_ACTION);
    intentFilter.addAction(IntentHandler.START_TRACKING_ACTION);
    intentFilter.addAction(IntentHandler.TRACK_REMOTE);
    intentFilter.addAction(IntentHandler.STOP_TRACKING_ACTION);
    intentFilter.addAction(IntentHandler.SPEED_TEST);
    intentFilter.addAction(IntentHandler.RUN_WEBSOCKET);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_START_UI);

    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_LOCATION_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_CELL_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_GPS_STATUS_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_SIGNAL_STRENGTH_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_EVENT_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_NEIGHBOR_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_NETWORK_UPDATE);
    //intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_RX_TX);

    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_RESULT);
    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_ERROR);
    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_COMPLETE);
    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_CANCELLED);

    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_RESULT);
    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_ERROR);
    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_COMPLETE);
    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_CANCELLED);

    //do not add filter if sms test permissions aren't all allowed
    if (PreferenceKeys.getSMSPermissionsAllowed(owner, true))
        intentFilter.addAction(IntentHandler.SMS_TEST);

    intentFilter.addAction(IntentHandler.SMS_DELIVERED);
    intentFilter.addAction(IntentHandler.LATENCY_TEST);
    intentFilter.addAction(IntentHandler.ACTION_STOP_SPEEDTEST);
    intentFilter.addAction(IntentHandler.RESTART_MMC_SERVICE);
    intentFilter.addAction(IntentHandler.COLDRESET_ACTION);
    intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
    intentFilter.addAction(Intent.ACTION_POWER_CONNECTED);
    intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
    intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    intentFilter.addAction(Intent.ACTION_SCREEN_ON);
    intentFilter.addAction(IntentHandler.COMMAND);
    intentFilter.addAction(IntentHandler.SURVEY);
    //intentFilter.addAction(Intent.ACTION_VIEW);
    //intentFilter.addAction("android.intent.PHONE_STATE");
    intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_TRACKING_5MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_TRACKING_1MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_3HOUR);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_15MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_SCANAPPS);
    intentFilter.addAction(IntentHandler.EMAIL_CSV);
    intentFilter.addAction(IntentHandler.GPS_STATE_OFF);
    intentFilter.addAction(IntentHandler.GPS_STATE_ON);
    intentFilter.addAction(IntentHandler.PHONE_CALL_CONNECT);
    intentFilter.addAction(IntentHandler.PHONE_CALL_DISCONNECT);
    intentFilter.addAction(IntentHandler.HANDOFF);
    //intentFilter.addAction(IntentHandler.SMS_SENT);
    intentFilter.addAction(IntentHandler.SMS_RECEIVED);
    intentFilter.addAction(Intent.ACTION_SEND);
    intentFilter.addAction(IntentHandler.MANUAL_PLOTTING_START);
    intentFilter.addAction(IntentHandler.MANUAL_PLOTTING_END);
    intentFilter.addAction(IntentHandler.MANUAL_PLOTTING_CANCEL);
    intentFilter.addAction(IntentHandler.MANUAL_TRANSIT_START);
    intentFilter.addAction(IntentHandler.MANUAL_TRANSIT_END);
    intentFilter.addAction(IntentHandler.MANUAL_TRANSIT_CANCEL);
    intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
    intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
    intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);

    intentFilter.addAction(Intent.ACTION_HEADSET_PLUG);
    intentFilter.addAction(IntentHandler.ROAMING_ON);
    intentFilter.addAction(IntentHandler.ROAMING_OFF);

    intentFilter.addAction(IntentHandler.VIEWING_SIGNAL);
    intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    intentFilter.addAction("android.intent.action.PRECISE_CALL_STATE");
    intentFilter.addAction("android.intent.action.PRECISE_DATA_CONNECTION_STATE_CHANGED");
    intentFilter.addAction("android.intent.action.PHONE_STATE");
    intentFilter.addAction("android.intent.action.NEW_OUTGOING_CALL");

    intentFilter.addAction("android.intent.action.DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN");
    intentFilter.addAction("android.intent.action.ANY_DATA_STATE");
    intentFilter.addAction("android.intent.action.ACTION_DATA_CONNECTION_FAILED");

    intentFilter.addAction(CommonIntentActionsOld.ACTION_BLUETOOTH_ENDDOWNLOAD);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_START_VOICETEST);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_STOP_VOICETEST);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_TEST_VQ_DEVICE);

    intentFilter.addAction(IntentHandler.ACTIVE_TEST);
    intentFilter.addAction(IntentHandler.ACTION_STOP_VIDEOTEST);
    intentFilter.addAction(IntentHandler.GCM_MESSAGE);

    intentFilter.addAction("org.restcomm.android.CONNECT_FAILED");
    intentFilter.addAction("org.restcomm.android.CALL_STATE");
    intentFilter.addAction("org.restcomm.android.DISCONNECT_ERROR");

    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_DISCONNECT);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_CONNECT);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_NEIGHBORS);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_SERVICEMODE);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_SERVICEMENU);
    intentFilter.addAction(IntentHandler.ACTION_MMCSYS_VERSION);

    //intentFilter.addAction(Intent.ACTION_APP_ERROR);
    int raisePriority = owner.getPackageManager().checkPermission("android.permission.RAISED_THREAD_PRIORITY",
            owner.getPackageName());// w  w  w .  jav a 2s.  c  om
    // With permission to raise priority for SMS messages
    if (raisePriority == 0)
        intentFilter.setPriority(9999999);

    return intentFilter;
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    isStopped = false;//  www  .  j ava2s.co 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();
}

From source file:com.wewow.MainActivity.java

public void regitsterNetSateBroadcastReceiver(Context context) {
    IntentFilter filter = new IntentFilter();
    filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    context.registerReceiver(mybroadcast, filter);
}