Code example for ConnectivityManager

Methods: getBackgroundDataSetting

0
	public void onReceive(Context context, Intent intent) {
		ConnectivityManager manager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		// Not sure what this does, but according documentation, if this is disabled, we should avoid all background data 
		if (intent.getAction().equals(android.net.ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED)) {
			SharedPreferences preferences = getSharedPreferences(context);
			if (manager.getBackgroundDataSetting() == false && preferences.getBoolean(Settings.AUTOMATIC_UPDATE, Settings.AUTOMATIC_UPDATE_DEFAULT)) {
				Editor editor = preferences.edit();
				editor.putBoolean(Settings.AUTOMATIC_UPDATE, false);
				editor.commit();
			} 
		} 
	} 
}