1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I identify the network usage in android application?

Discussion in 'Android' started by manojrawat77, Sep 7, 2015.

  1. manojrawat77

    manojrawat77 New Member

    Joined:
    Sep 7, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    I have built an android application, and I want to figure out how much network usage this android application is utilizing. I have explored many android developer forum to get a satisfactory solution but didn't get it. I hope some of the tech experts in this community can help to figure out my issue.:confused:
     
  2. mialuzzatto

    mialuzzatto New Member

    Joined:
    Aug 5, 2015
    Messages:
    122
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Work at https://www.idevelopersquare.com
    Location:
    Waltham, MA, USA
    Home Page:
    Hello,

    Did not try . See if this can help
    Code:
    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.
     

Share This Page