Code example for ConnectivityManager

Methods: getBackgroundDataSetting

0
     */ 
    private static boolean getBackgroundDataState(Context context) {
        ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        return connManager.getBackgroundDataSetting();
    } 
 
    /** 
     * Toggle background data and sync tickles. 
     * 
     * @param context 
     */ 
    private void toggleBackgroundData(Context context) {
        ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        boolean sync = getBackgroundDataState(context);
        connManager.setBackgroundDataSetting(!sync);
 
        IContentService contentService = ContentResolver.getContentService();
        try { 
            contentService.setListenForNetworkTickles(!sync);
        } catch (RemoteException e) {
            Log.d(TAG, "toggleBackgroundData: " + e);