Code example for TelephonyManager

Methods: getDataState

0
     * @param context a reference to Context or Activity 
     * @return true if data enabled. 
     */ 
    public static boolean   isEnable(Context context) {
        TelephonyManager tmanager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return (tmanager.getDataState() == TelephonyManager.DATA_CONNECTED);
    } 
 
    /** 
     * Turn off mobile data. 
     * 
     * @param context a reference to Context or Activity 
     */ 
    public static void      disable(Context context) {
        switchState(context, false);
    } 
 
    /** 
     * Turn on mobile data. 
     * 
     * @param context a reference to Context or Activity