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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With