is Wifi Connected Or Connecting - Android Phone

Android examples for Phone:wifi

Description

is Wifi Connected Or Connecting

Demo Code


//package com.java2s;

import android.content.Context;

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

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

        return ni.isConnectedOrConnecting();
    }/* w w  w  .j a v a 2 s  .  c o m*/
}

Related Tutorials