is Mobile Connected - Android Phone

Android examples for Phone:Network

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.  j a v  a 2  s .c  o m
}

Related Tutorials