Making your application’s data usage preferences available from system settings

Android 4.0+ gives users the ability to monitor the amount of mobile data being used on their device, and in some cases, automatically turn off mobile data.
You can access the Data Usage settings screen by opening the Settings app, and then selecting Data Usage.

In Android 4.0+ if you create a Preference Activity to allow users to modify your application’s data usage, you can make it available from within the system settings when a user inspects your application’s data usage.

It is very simple: just add a MANAGE_NETWORK_USAGE Intent Filter to the Preference Activity’s manifest node:
<activity android:name=".PreferencesActivitySummary" android:theme="@style/AppThemeABS">
    <intent-filter>
         <action android:name="android.intent.action.MANAGE_NETWORK_USAGE"/>
         <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>            
</activity>
Once set, the View Application Settings button in the system settings will launch your Preference Activity, allowing users to refine your application’s data usage rather than restricting or disabling it.


Comments

Popular posts from this blog

AntiPattern: freezing a UI with Broadcast Receiver

How to centralize the support libraries dependencies in gradle

NotificationListenerService and kitkat