Preethi
Preethi

Reputation: 2152

How to enable the background data settings in android?

How do I enable Settings->Accounts and Sync->Background data programatically in ice cream sandwich ?

Upvotes: 1

Views: 4274

Answers (2)

san
san

Reputation: 1835

You cannot do it programatically. Only user has that privillege. How ever you can check whether he has enabled or not using .

ConnectivityManager mgr = (ConnectivityManager)Context.getSystemService(Context.CONNECTIVITY_SERVICE);
boolean bgData = mgr.getBackgroundDataSetting();

And request the user to set by opening the settings. Use ACTION_SYNC_SETTINGS for your intent. You have to make sure before sending it that the intent will resolve though, as some devices may not be able to interpret that intent. If they can't, send ACTION_SETTINGS instead, possibly with a note to the user telling them where the sync settings are (if your users aren't expected to be very tech savvy).

Upvotes: 4

Vikram Bodicherla
Vikram Bodicherla

Reputation: 7123

You cannot enable it programmatically. That is only for the user to do. If you could turn it off and on programmatically, why would it be a UI option at all!?

Upvotes: 0

Related Questions