Example usage for android.net.wifi SupplicantState SCANNING

List of usage examples for android.net.wifi SupplicantState SCANNING

Introduction

In this page you can find the example usage for android.net.wifi SupplicantState SCANNING.

Prototype

SupplicantState SCANNING

To view the source code for android.net.wifi SupplicantState SCANNING.

Click Source Link

Document

Scanning for a network.

Usage

From source file:com.ultrafunk.network_info.service.NetworkStateService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if ((intent != null) && (intent.getAction() != null)) {
        final String action = intent.getAction();

        //   Log.e(this.getClass().getSimpleName(), "onStartCommand(): " + action);

        if (Constants.ACTION_UPDATE_SERVICE_STATE.equals(action)) {
            initEnabledWidgets(new EnabledWidgets(
                    intent.getBooleanExtra(Constants.EXTRA_ENABLED_WIDGETS_MOBILE_DATA, false),
                    intent.getBooleanExtra(Constants.EXTRA_ENABLED_WIDGETS_WIFI, false)));
        } else {//from   www  .j av a 2  s. co m
            final Handler handler = new Handler();

            if (Constants.ACTION_WIFI_CONNECTING.equals(action)) {
                handler.postDelayed(new Runnable() {
                    public void run() {
                        WifiInfo wifiInfo = wifiManager.getConnectionInfo();

                        if ((wifiInfo != null) && (wifiInfo.getSupplicantState() == SupplicantState.SCANNING))
                            localBroadcastManager.sendBroadcastSync(new Intent(Constants.ACTION_WIFI_SCANNING));
                    }
                }, 5 * 1000);
            } else if (Constants.ACTION_WIFI_CONNECTED.equals(action)) {
                handler.postDelayed(new Runnable() {
                    public void run() {
                        WifiInfo wifiInfo = wifiManager.getConnectionInfo();

                        if ((wifiInfo != null) && (wifiInfo.getLinkSpeed() != -1))
                            localBroadcastManager
                                    .sendBroadcastSync(new Intent(Constants.ACTION_WIFI_LINK_SPEED));
                    }
                }, 3 * 1000);
            } else if (Constants.ACTION_DATA_CONNECTED.equals(action)) {
                handler.postDelayed(new Runnable() {
                    public void run() {
                        isWaitingForDataUsage = false;

                        if (telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED)
                            localBroadcastManager
                                    .sendBroadcastSync(new Intent(Constants.ACTION_DATA_USAGE_UPDATE));
                    }
                }, 500);
            }
        }
    }

    return Service.START_STICKY;
}

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

private void setSupplicantStateText(SupplicantState supplicantState) {
    if (SupplicantState.FOUR_WAY_HANDSHAKE.equals(supplicantState)) {
        mSupplicantState.setText("FOUR WAY HANDSHAKE");
    } else if (SupplicantState.ASSOCIATED.equals(supplicantState)) {
        mSupplicantState.setText("ASSOCIATED");
    } else if (SupplicantState.ASSOCIATING.equals(supplicantState)) {
        mSupplicantState.setText("ASSOCIATING");
    } else if (SupplicantState.COMPLETED.equals(supplicantState)) {
        mSupplicantState.setText("COMPLETED");
    } else if (SupplicantState.DISCONNECTED.equals(supplicantState)) {
        mSupplicantState.setText("DISCONNECTED");
    } else if (SupplicantState.DORMANT.equals(supplicantState)) {
        mSupplicantState.setText("DORMANT");
    } else if (SupplicantState.GROUP_HANDSHAKE.equals(supplicantState)) {
        mSupplicantState.setText("GROUP HANDSHAKE");
    } else if (SupplicantState.INACTIVE.equals(supplicantState)) {
        mSupplicantState.setText("INACTIVE");
    } else if (SupplicantState.INVALID.equals(supplicantState)) {
        mSupplicantState.setText("INVALID");
    } else if (SupplicantState.SCANNING.equals(supplicantState)) {
        mSupplicantState.setText("SCANNING");
    } else if (SupplicantState.UNINITIALIZED.equals(supplicantState)) {
        mSupplicantState.setText("UNINITIALIZED");
    } else {/*from   w  w  w . j a  v  a2 s.c o  m*/
        mSupplicantState.setText("BAD");
        Log.e(TAG, "supplicant state is bad");
    }
}