is On Wifi Net - Android Wifi

Android examples for Wifi:Wifi Connection

Description

is On Wifi Net

Demo Code


//package com.java2s;

import android.content.Context;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

public class Main {
    public static Boolean isOnWifiNet(Context context) {
        boolean isWifi = false;

        ConnectivityManager connManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = connManager.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnected()) {
            isWifi = (netInfo.getType() == ConnectivityManager.TYPE_WIFI);
            Log.d("IsOnWifiNet", isWifi + "");
        }//  w  ww . java  2 s. c  om

        return isWifi;
    }
}

Related Tutorials