Reputation: 1756
In ICS there is now the "Restrict background data" setting in the Network -> Data usage settings screens.
Is there a way to programmatically set "Restrict background data" for my application?
OR
Is there a way to bring up the "Data usage" settings that has the option for my application?
Upvotes: 6
Views: 3367
Reputation: 380
You can start from the Overview of Data Usage Android Tech Info page.
Each network device driver will report its usage statsitics to xt_qtaguid
module in the android-3.0 Linux kernel. Then, from the framework you can specify additional rules to restrict background data traffic for an application.
Try providing counterSet
and UID
params to com.android.server.NetworkManagementSocketTagger
setKernelCounterSet()
method. Where counterSet
values are defined in android.net.NetworkPolicyManager
and UID
would be your application id obtained through ContextWrapper.getApplicationInfo().uid
.
I hope this gets you started.
Upvotes: 3
Reputation: 5212
As for your second option, you may look into this intent
"Activity Action: Show settings for managing network data usage of a specific application."
Upvotes: 0