Internet usage(Data usage) by WebView
Asked Answered
P

2

10

I have used WebView for browsing in my application, now i want to get internet usage by my WebView. Is it possible in android?

I have searched a lot but not getting even a single hint. Can anyone help me?

I know you will ask me what have you tried so far, but i didn't get anything from research. If anyone can give me hint, i am not asking for full code or example.

I have created simple webview and its working fine

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/webView1"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
/>
Polypody answered 24/2, 2016 at 10:38 Comment(6)
stackoverflow.com/a/11940219Facelift
@Facelift thanks but i have checked, it is giving me whole application data usage, i want just for WebView.Polypody
i think you can convert that in to what ever you wantFacelift
yes, but i am having multiple webviews and multiple APIs. So i want to get data usage by different webviews.Polypody
can you able to write a class using that link which will return the data use from where ever you want ?Facelift
you mean how much data is getting consumed by webview?Weigel
T
6

There is no means for you to determine the bandwidth consumed just by your WebView.

Depending on how your app is written, if you can determine how much bandwidth you are using outside of WebView, you can use TrafficStats to determine your whole app's bandwidth uses, and then subtract the two values to determine what is inside the WebView.

Thundersquall answered 28/2, 2016 at 15:33 Comment(0)
C
1

Webview essentially is a DOM Tree which renders objects. It parses your HTML tags , creates elements and helps draw objects on a webpage. All the request for download goes as an http/https etc. request to android framework services. The webview does not know how much of data has been downloaded. It only requests for data and receives the contents/response back.

You should look into the code of Data usage activity/fragment in Settings applications. This will tell you how it monitors and tracks data of various applications but there is no suupport present in the framework(yet) to know which webview has downloaded how much content.

Curren answered 4/3, 2016 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.