make true current connect service is wifi - Android android.net.wifi

Android examples for android.net.wifi:Wifi Connection

Description

make true current connect service is wifi

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {

  public static boolean isWifi(Context mContext) {
    ConnectivityManager connectivityManager = (ConnectivityManager) mContext
        .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
    if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
      return true;
    }/*from w  ww.j av  a  2 s  .c  o m*/
    return false;
  }

}

Related Tutorials