Search code examples
android-wifiandroid

How to obtain amount of transferred data through Wi-Fi from other applications?


I'm facing to this problem. I spent much time by searching some API or "something" with it's possible to obtain transferred data through Wi-Fi from other applications (how screenshot bellow shows).

Does someone know a way how to do it? Is here someone who tried (or has already done) for something similar? Or a little differently: Is this possible to do it?

Currently i think that this is not possible because i think that non-system application cannot retrieve data from other application(s) installed on device. But maybe i can "missing" something so i placed this question and will be glad for whatever suggestion.

Thanks in advance!

enter image description here


Solution

  • TrafficStats

    Class that provides network traffic statistics. These statistics include bytes transmitted and received and network packets transmitted and received, over all interfaces, over the mobile interface, and on a per-UID basis.
    

    This means you can use getUidTxBytes to get whole transmitted data and so far getUidRxBytes to get whole received data.

    And you can get application's UID with:

    getApplicationInfo().uid 
    

    or for other applications refer THIS