How can I identify the network usage in android application ?

  • Replies:1
Ranjeet Kumar
  • Forum posts: 15

Jul 31, 2015, 11:06:02 AM via Website

I have built an android application, and I want to figure out how much network usage this android application is utilizing. Looking for a quick reply from this android developer forum, hope I will get correct solutions to my query.

Reply
Ashish Tripathi
  • Forum posts: 211

Aug 5, 2015, 9:06:14 AM via Website

Did not try . See if this can help

ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List runningApps = manager.getRunningAppProcesses();

    for(RunningAppProcessInfo runningApp : runningApps){
      // Get UID of the selected process
        int uid = ((RunningAppProcessInfo)getListAdapter().getItem(position)).uid;

      // Get traffic data
        long received = TrafficStats.getUidRxBytes(uid);
        long send   = TrafficStats.getUidTxBytes(uid);
        Log.v(""+uid ,"Send :"+send +", Received :"+received);
    }

if not share. you can identify your app with package name.

cheers

Reply