is Mobile Connected Or Connecting - Android Network

Android examples for Network:Network Status

Description

is Mobile 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 isMobileConnectedOrConnecting(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

        return ni.isConnectedOrConnecting();
    }/*  w w w. j av a2  s  .  c  om*/
}

Related Tutorials