Android Open Source - wifiManager Wifi Connect Broad Cast






From Project

Back to project page wifiManager.

License

The source code is released under:

Apache License

If you think the Android project wifiManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.txmcu.WifiManager;
/*from   w  w  w  . j  ava2 s. c  o m*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Parcelable;
import android.util.Log;

import com.txmcu.WifiManager.WifiHotManager.WifiBroadCastOperations;

public class WifiConnectBroadCast extends BroadcastReceiver {

  private WifiBroadCastOperations operations;

  private WifiManager wifiManager;
  private String sSID;

  public WifiConnectBroadCast(WifiBroadCastOperations operations,String SSID) {

    this.operations = operations;
    this.sSID = SSID;
  }

  @Override
  public void onReceive(Context context, Intent intent) {
    
    
    if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
      Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
      if (null != parcelableExtra) {
        NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
        wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        String SSID = wifiInfo.getSSID();
        
        switch (networkInfo.getState()) {
        case CONNECTED:
          Log.e("APActivity", "CONNECTED");
          //if (SSID.contains(sSID)) {
            operations.disPlayWifiConResult(true, wifiInfo);
          //} else {
          //  operations.disPlayWifiConResult(false, wifiInfo);
          //}
          break;
        case CONNECTING:
          Log.e("APActivity", "CONNECTING");
          operations.disPlayWifiConResult(false, wifiInfo);
          break;
        case DISCONNECTED:
          Log.e("APActivity", "DISCONNECTED");
          operations.disPlayWifiConResult(false, wifiInfo);
          break;
        case DISCONNECTING:
          Log.e("APActivity", "DISCONNECTING");
          operations.disPlayWifiConResult(false, wifiInfo);
          break;
        case SUSPENDED:
          Log.e("APActivity", "SUSPENDED");
          operations.disPlayWifiConResult(false, wifiInfo);
          break;
        case UNKNOWN:
          Log.e("APActivity", "UNKNOWN");
          operations.disPlayWifiConResult(false, wifiInfo);
          break;
        default:
          break;
        }
      }
    }
  }
}




Java Source Code List

com.txmcu.WifiManager.Global.java
com.txmcu.WifiManager.WifiConnectBroadCast.java
com.txmcu.WifiManager.WifiHotAdmin.java
com.txmcu.WifiManager.WifiHotConfigAdmin.java
com.txmcu.WifiManager.WifiHotManager.java
com.txmcu.WifiManager.WifiScanRsultBroadCast.java
com.txmcu.WifiManager.WifiStateBroadCast.java
com.txmcu.wifimanagerdemo.AddDeviceActivity.java
com.txmcu.wifimanagerdemo.MainActivity.java
com.txmcu.wifimanagerdemo.SettingActivity.java
com.txmcu.wifimanagerdemo.XiaoXinAdapter.java
com.txmcu.wifimanagerdemo.XiaoxinInfo.java
com.txmcu.xiaoxin.Udpclient.java
com.txmcu.xiaoxin.XinStateManager.java