Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet usage(Data usage) by WebView

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"
/>
like image 479
Ravi Avatar asked Feb 24 '16 10:02

Ravi


People also ask

How can I monitor my daily data usage?

If you use an Android device, you can add the Google Fi widget to your home screen to have your data usage on hand at all times. Go to the Account tab. At the top of the screen, you'll see your current data usage. Android: To see your daily breakdown select View overall or Daily data usage.

Why is my phone using so much WIFI?

Check Data Usage in Settings Check to see which apps are using data. On many newer Android devices, you can go to “Settings” > “Data Usage” > “Cellular data usage“, then scroll down to see which apps are using the most data.

Why does wifi use so much data?

Several factors contribute to high usage, but much of it comes down to frequent activity. If you have devices such as computers, tablets, smartphones or security cameras that are constantly running, it's likely your usage numbers will be high.


2 Answers

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.

like image 69
CommonsWare Avatar answered Oct 06 '22 16:10

CommonsWare


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.

like image 38
user1649464 Avatar answered Oct 06 '22 17:10

user1649464