Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.net.ConnectivityManager; import java.lang.reflect.Method; public class Main { public static boolean isMobileEnabled(Context context) { try { Method e = ConnectivityManager.class.getDeclaredMethod("getMobileDataEnabled", new Class[0]); e.setAccessible(true); return ((Boolean) e.invoke(getConnManager(context), new Object[0])).booleanValue(); } catch (Exception var2) { var2.printStackTrace(); return true; } } public static ConnectivityManager getConnManager(Context context) { return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); } }