1

I found how to get data usage from the TrafficStats class, but there's nothing specific about tethering data usage.

How can I get data usage for tethering? Is there any specific UID to target using the TrafficStats mothods?

tshepang
  • 12,111
  • 21
  • 91
  • 136

2 Answers2

0

Tethering seems a system process. Try to read data of these system processes. Visit this link http://agolovatyuk.blogspot.in/2012/04/android-traffic-statistics-inside.html

Ajit
  • 724
  • 7
  • 16
  • Sorry link is not dead. Under the link, list of system processes is shown as well as location where data usage by these processes is shown. Use File reader to read these data. For UID of tethering you have to hit and trial. – Ajit Mar 20 '14 at 10:09
0

https://developer.android.com/reference/android/app/usage/NetworkStatsManager.html>>
use network stats manager API.
You could use queryDetailsForUid() UID for tethering is (UID_TETHERING) -5 .
use permission
< uses-permission-sdk-23 android:name="android.permission.PACKAGE_USAGE_STATS"/ >
getSubcriber id from telephony manager
which needs < uses-permission android:name="android.permission.READ_PHONE_STATE"/ >
NOTE:works only from api 23

Sree Vishnu
  • 385
  • 2
  • 13