How to measure Android WebView inbound/outbound traffic

Go To StackoverFlow.com

1

Is it possible to measure Android WebView inbound/outbound traffic?

My task is to measure all network activity performed by my app. As far as I understood TrafficStats class has serious limitations. It may not work under some circumstances. And it also appeared only in API 8, whereas I have to support 7 also. So using it is an option for me only for the case when I won't find any other solution.

Note, that all other network traffic is easily measured, as it is controlled by my app. so the problem is only that part that is issued/received by WebView component.

Thanks.

2012-04-05 15:04
by user613036


1

Is it possible to measure Android WebView inbound/outbound traffic?

Use TrafficStats, or use something outside of your device (e.g., some proxy server that can record this information).

As far as I understood TrafficStats class has serious limitations.

You are certainly welcome to your opinion.

And it also appeared only in API 8, whereas I have to support 7 also.

Unless you have significantly different behavior in your app specific to API Level 7, the bandwidth consumed by your WebView probably does not change much. Set your build target to API Level 8 and use TrafficStats on API Level 8+ devices (by means of a Build.VERSION.SDK_INT check).

2012-04-05 16:04
by CommonsWare
Thanks a lot for the detailed answer. It helped. By "limitations" i meant that the class is accessible only after API8 and also that sometimes methods can return UNSUPPORTED in case when device does not support the statistics. I will switch off traffic counting for API < 8 devices - user613036 2012-04-09 08:25
Ads