Example usage for android.net.wifi WifiManager RSSI_CHANGED_ACTION

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

Introduction

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

Prototype

String RSSI_CHANGED_ACTION

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

Click Source Link

Document

The RSSI (signal strength) has changed.

Usage

From source file:com.geniatech.client_phone.wifi.WifiStatusTest.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);

    mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
    mWifiStateFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);

    registerReceiver(mWifiStateReceiver, mWifiStateFilter);

    setContentView(R.layout.wifi_status_test);

    updateButton = (Button) findViewById(R.id.update);
    updateButton.setOnClickListener(updateButtonHandler);

    mWifiState = (TextView) findViewById(R.id.wifi_state);
    mNetworkState = (TextView) findViewById(R.id.network_state);
    mSupplicantState = (TextView) findViewById(R.id.supplicant_state);
    mRSSI = (TextView) findViewById(R.id.rssi);
    mBSSID = (TextView) findViewById(R.id.bssid);
    mSSID = (TextView) findViewById(R.id.ssid);
    mHiddenSSID = (TextView) findViewById(R.id.hidden_ssid);
    mIPAddr = (TextView) findViewById(R.id.ipaddr);
    mMACAddr = (TextView) findViewById(R.id.macaddr);
    mNetworkId = (TextView) findViewById(R.id.networkid);
    mLinkSpeed = (TextView) findViewById(R.id.link_speed);
    mScanList = (TextView) findViewById(R.id.scan_list);

}

From source file:com.hzl.administrator.wifi.WifiStatusTest.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);

    mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
    mWifiStateFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
    mWifiStateFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);

    registerReceiver(mWifiStateReceiver, mWifiStateFilter);

    setContentView(R.layout.wifi_status_test);

    updateButton = (Button) findViewById(R.id.update);
    updateButton.setOnClickListener(updateButtonHandler);

    mWifiState = (TextView) findViewById(R.id.wifi_state);
    mNetworkState = (TextView) findViewById(R.id.network_state);
    mSupplicantState = (TextView) findViewById(R.id.supplicant_state);
    mRSSI = (TextView) findViewById(R.id.rssi);
    mBSSID = (TextView) findViewById(R.id.bssid);
    mSSID = (TextView) findViewById(R.id.ssid);
    mHiddenSSID = (TextView) findViewById(R.id.hidden_ssid);
    mIPAddr = (TextView) findViewById(R.id.ipaddr);
    mMACAddr = (TextView) findViewById(R.id.macaddr);
    mNetworkId = (TextView) findViewById(R.id.networkid);
    mLinkSpeed = (TextView) findViewById(R.id.link_speed);
    mScanList = (TextView) findViewById(R.id.scan_list);

    mPingIpAddr = (TextView) findViewById(R.id.pingIpAddr);
    mPingHostname = (TextView) findViewById(R.id.pingHostname);
    mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);

    pingTestButton = (Button) findViewById(R.id.ping_test);
    pingTestButton.setOnClickListener(mPingButtonHandler);
}

From source file:com.allthingsgeek.celljoust.MainActivity.java

private synchronized void startListening() {
    Log.d(TAG, "startListening called");

    convWorker = new ConversionWorker();

    if (state == null) {
        state = new RobotStateHandler(handler);
        state.start();/*from ww  w .ja  v a 2  s.c om*/
        while (state.handler == null) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
            }
        }

    }

    if (sensorListener == null) {
        sensorListener = new SensorListenerImpl(state.handler, wifiManager);
    }

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    RobotStateHandler.ROBOT_ID = settings.getString("ROBOT_ID", RobotStateHandler.ROBOT_ID);

    // Toast.makeText(CONTEXT, "Current IP:" + state.getLocalIpAddress(),
    // Toast.LENGTH_LONG);
    // ProgressDialog.show(me, msg,
    // "Searching for a Bluetooth serial port...");

    ProgressDialog btDialog = null;

    String connectivity_context = Context.WIFI_SERVICE;
    WifiManager wifi = (WifiManager) getSystemService(connectivity_context);

    this.registerReceiver(sensorListener.mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    this.registerReceiver(sensorListener.mWifiInfoReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));

    if (OrientationManager.isSupported()) {
        OrientationManager.startListening(sensorListener);
    }

    if (LightSensorManager.isSupported()) {
        LightSensorManager.startListening(sensorListener);
    }

    if (CompassManager.isSupported()) {
        CompassManager.startListening(sensorListener);
    }

}

From source file:at.alladin.rmbt.android.util.InformationCollector.java

private void registerNetworkReceiver() {
    if (networkReceiver == null && registerNetworkReiceiver) {
        networkReceiver = new NetworkStateBroadcastReceiver();
        IntentFilter intentFilter;//from w  ww  .  jav  a 2s .  c o m
        intentFilter = new IntentFilter();
        // intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
        intentFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
        Log.d(DEBUG_TAG, "registering receiver");
        context.registerReceiver(networkReceiver, intentFilter);
    }
}

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

private static void createWifiReceiver(final Context context) {
    if (wifiReceiver != null)
        return;//from   www. j  a  v  a  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.vonglasow.michael.satstat.ui.MainActivity.java

@Override
protected void onStart() {
    super.onStart();
    isStopped = false;/*  w w  w.  jav a2  s.c o  m*/
    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 a v a2 s  .com
    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();
}