is Mobile Connected Or Connecting - Android Phone

Android examples for Phone:Network

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();
    }/*from w  w w . ja  v  a 2 s . c o m*/
}

Related Tutorials