is Mobile Data Enable - Android android.net

Android examples for android.net:ConnectivityManager

Description

is Mobile Data Enable

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;

public class Main {

  public static boolean isMobileDataEnable(Context context) throws Exception {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
    boolean isMobileDataEnable = false;

    isMobileDataEnable = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();

    return isMobileDataEnable;
  }//from   ww  w.j a  va 2s .  c o m

}

Related Tutorials