get Network Info from ConnectivityManager - Android Network

Android examples for Network:Network Operation

Description

get Network Info from ConnectivityManager

Demo Code


//package com.java2s;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static NetworkInfo getNetworkInfo(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        return cm.getActiveNetworkInfo();
    }/*ww w . ja  v a2 s.c o  m*/
}

Related Tutorials