Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify content before rendering in Android WebView?

I am making a custom simple web browser for Android and needed to capture the content of every page the user browses and manipulate it before rendering so that it displays as expected.

I don't want to break user login state and interaction, so I don't want to intercept the POST request or cookies.

So far as I know, I can put the content with loadDataWithBaseURL(). However, to make a better user experience, I wan to get the content and manipulate before the user sees it, and if possible, before images being downloaded (like DOMReady in JS), but had no clue how to do it.

What is the best place to listen to, and how can I get the current webview content?

Since I am new to Android development, I was looking for a good advice for the solution. Thanks.

like image 291
Muhammad Ababekri Avatar asked Mar 31 '13 10:03

Muhammad Ababekri


1 Answers

you can use shouldInterceptRequest method. there is an example:

webview shouldinterceptrequest example

Hope this is useful.

like image 100
Behrouz.M Avatar answered Oct 02 '22 16:10

Behrouz.M