How do I use TrafficStats.incrementOperationCount ()?

The documentation for TrafficStats.incrementOperationCount()

says:

An increase in the number of network operations performed under a given accounting tag. This can be used to output bytes per operation.

I want to find the total number of bytes transferred during a specific network operation. Since this API claims to help in getting bytes per operation, can anyone help me understand how to use it?

+3


source to share


2 answers


CountingInputStream CountingOutputStream I'm not sure if this will help you or not, but I find it helpful to get the number of bytes sent and received in a particular stream.



you can format its actual use, create logic such that the addition (number per byte sent and received) is the total number of bytes transferred during a particular network operation.

+2


source


Not sure what you really want to do, but maybe this example can help: http://www.techrepublic.com/blog/app-builder/create-a-network-monitor-using-androids-trafficstats-class/ 774



Another possible way to do this is to use a sniffer like https://play.google.com/store/apps/details?id=vadim.ofer.sniffer&hl=en

0


source







All Articles