Example usage for android.net.wifi WifiManager SUPPLICANT_STATE_CHANGED_ACTION

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

Introduction

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

Prototype

String SUPPLICANT_STATE_CHANGED_ACTION

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

Click Source Link

Document

Broadcast intent action indicating that the state of establishing a connection to an access point has changed.One extra provides the new SupplicantState .

Usage

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  ava 2  s  .  c o  m

    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: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:org.exobel.routerkeygen.AutoConnectService.java

private void tryingConnection() {
    currentNetworkId = Wifi.connectToNewNetwork(this, wifi, network, keys.get(attempts++),
            mNumOpenNetworksKept);//  w w  w  . jav  a  2s .c o m
    Log.d(AutoConnectManager.class.getSimpleName(), "Trying " + keys.get(attempts - 1));

    if (currentNetworkId != -1) {
        lastTimeDisconnected = System.currentTimeMillis();
        registerReceiver(mReceiver, new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
        mNotificationManager.notify(UNIQUE_ID, createProgressBar(getString(R.string.app_name),
                getString(R.string.not_auto_connect_key_testing, keys.get(attempts - 1)), attempts));
    } else {
        mNotificationManager.notify(UNIQUE_ID,
                getSimple(getString(R.string.msg_error), getString(R.string.msg_error_key_testing)).build());
        stopSelf();
    }
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

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

    app_ini = true;//from  w w w .j  a  v a 2  s  .c  o  m
    // during start up of application we define our current date
    final Calendar c = Calendar.getInstance();
    ToDay = Common.TwoDigits(c.get(Calendar.DAY_OF_MONTH)) + "-" + Common.TwoDigits(c.get(Calendar.MONTH) + 1)
            + "-" + Common.FourDigits(c.get(Calendar.YEAR));
    Log.d(TAG, "Started, date = " + ToDay);
    if (!getSettings(context)) {
        SharedPreferences prefs = context.getSharedPreferences("Share", Context.MODE_PRIVATE);
        prefs.edit().clear();
        SharedPreferences.Editor es = prefs.edit();
        es.putString("com.ezac.gliderlogs.url", "host").apply();
        es.putString("com.ezac.gliderlogs.pre", "45").apply();
        es.putString("com.ezac.gliderlogs.scn", "300").apply();
        es.putString("com.ezac.gliderlogs.key", "").apply();
        es.putString("com.ezac.gliderlogs.sct", "").apply();
        es.putString("com.ezac.gliderlogs.mst", "6319").apply();
        es.putString("com.ezac.gliderlogs.mtr", "EHFS;EFWO").apply();
        es.putString("com.ezac.gliderlogs.ntp", "").apply();
        es.putString("com.ezac.gliderlogs.flg", "false;false;true;true;true;true;false;false;false;false")
                .apply();
        es.putString("com.ezac.gliderlogs.lnd", "O   - W").apply();
    }
    String v[] = appFLG.split(";");
    // check for loaded (glider / member) tables
    checktable(Boolean.parseBoolean(v[1]));
    // remove previous day(s) and/or already processed flights from table
    getTableFlightsCnt(ToDay, Boolean.parseBoolean(v[0]) ? 2 : 1);
    // check for unprocessed flights which are older than today
    if ((prev_cnt = getTableFlightsCnt(ToDay, 0)) != 0) {
        makeToast("Er zijn nog " + prev_cnt + " vluchten van een vorige vliegdag gevonden,"
                + "\ndeze zullen, zodra er een WiFi verbinding is, alsnog"
                + "\nworden verzonden naar de server maar NIET zichtbaar zijn"
                + "\nin het overzicht voor deze vliegdag.", 1);
    }
    // normal execution may proceed
    setContentView(R.layout.start_list);
    this.getListView().setDividerHeight(2);
    //
    fillData();
    registerForContextMenu(getListView());
    // starts our handler activity after 1 minute
    scan.postDelayed(runnable, 60000);
    // load data for spinner into array list
    addItemSpinner_1();
    addItemSpinner_2();
    // left in place as to potential add next section in future disable screen lock
    /*
            PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
            wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
        | PowerManager.ACQUIRE_CAUSES_WAKEUP
        | PowerManager.ON_AFTER_RELEASE, "INFO");
            wl.acquire();
            this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
       | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
       | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
       | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
       | WindowManager.LayoutParams.FLAG_FULLSCREEN
       | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
       | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
       | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
            
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
     */
    // disable screen hide
    getListView().setKeepScreenOn(true);
    // setup event receiver for wifi
    IntentFilter filter = new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
    this.registerReceiver(wifiStatusReceiver, filter);
}

From source file:com.moez.QKSMS.mmssms.Transaction.java

/**
 * @deprecated//from w  ww. j  av a2 s .c  o m
 */
private void revokeWifi(boolean saveState) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

    if (saveState) {
        settings.currentWifi = wifi.getConnectionInfo();
        settings.currentWifiState = wifi.isWifiEnabled();
        wifi.disconnect();
        settings.discon = new DisconnectWifi();
        context.registerReceiver(settings.discon,
                new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
        settings.currentDataState = Utils.isMobileDataEnabled(context);
        Utils.setMobileDataEnabled(context, true);
    } else {
        wifi.disconnect();
        wifi.disconnect();
        settings.discon = new DisconnectWifi();
        context.registerReceiver(settings.discon,
                new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
        Utils.setMobileDataEnabled(context, true);
    }
}