is Wifi Connected - Android Phone

Android examples for Phone:wifi

Description

is Wifi Connected

Demo Code


//package com.java2s;

import android.content.Context;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isWifiConnected(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        boolean isWifiConnected = ni.isConnected();
        return isWifiConnected;
    }/*from w w  w  .  jav  a 2s  . c  o m*/
}

Related Tutorials