aten100
aten100

Reputation: 25

How to manipulate URL on link click in Android WebView

I pulled a website to a WebView via HTTP GET. The problem is that the website isn't formatted for mobile. I found that if I edit the HTML, I can comment out the scripting that makes the left pane on the site.

Method: Download page to string, search string for and replace first substring <link with <!--, write to file, and load into the WebView.

That works great until it comes to a link. Clicking on it causes the WebView to attempt to load file:///index.php/Whatever_the_page_was.

What I want to do is capture that link request and change the file:/// part to www.wurmpedia.com, and then run it through my parser to remove the script like the first, and repeat the process on any other link click that follows.

I could not find any other way to pull this off and this is what I made up. Any help would be appreciated, either through URL modification or with a more efficient method.

Upvotes: 2

Views: 2031

Answers (1)

ChinLoong
ChinLoong

Reputation: 1833

How about intercepting the link request using

WebView.shouldInterceptRequest

Upvotes: 1

Related Questions