Code example for ConnectivityManager

Methods: setMobileDataEnabled

0
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (enabled) {
            cm.setMobileDataEnabled(false);
        } else { 
            cm.setMobileDataEnabled(true);
        } 
    } 
 
    @Override 
    public void updateState(Context context) {
        mContext = context;
        boolean useCustomExp = Settings.System.getInt(mContext.getContentResolver(),
        Settings.System.NOTIF_EXPANDED_BAR_CUSTOM, 0) == 1; 
 
        if (stateChangeRequest) {
            if (useCustomExp) {
                currentIcon = R.drawable.stat_data_on_cust; 
            } else { 
                currentIcon = R.drawable.stat_data_on; 
            }