How to get Tethering and Mobile Hotspot data usage in Android using NetworkStatusManager or TrafficStat

梦想的初衷 提交于 2021-01-28 09:14:54

问题


I have an Android application which displaying data usage per app by NetworkStatusManager, but I can't get data usage for Tethering and Mobile Hotspot. How should I do this?


回答1:


You need to query by UID and pass in the tethering UID: android.app.usage.NetworkStats.Bucket.UID_TETHERING like so:

networkStatsManager.queryDetailsForUid(ConnectivityManager.TYPE_MOBILE,
    subscriberId, startDate, endDate, 
    android.app.usage.NetworkStats.Bucket.UID_TETHERING);


来源:https://stackoverflow.com/questions/48005563/how-to-get-tethering-and-mobile-hotspot-data-usage-in-android-using-networkstatu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!