is Mobile Connected - Android Network

Android examples for Network:Network Status

Description

is Mobile Connected

Demo Code


//package com.java2s;

import android.content.Context;

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

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

        boolean isMobileConnected = ni.isConnected();
        return ni.isConnected();
    }/*from  w ww  .ja v  a2s  . co  m*/
}

Related Tutorials