Thursday, February 20, 2014

Help: android2.2 webview when the page is loaded, the ability to use local resources to replace the page resource (such as images, css, etc.)?


RT, above 3.0 sdk in, WebViewClient provides shouldInterceptRequest (WebView view, String url) method, you can intercept url corresponding resources (images, css) request, and can replace this resource manual, so as to achieve load faster, save traffic purposes, is now tangled, which is only 3.0 interface, to achieve similar functionality in 2.2 on how to achieve it?<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
First get to the page content, according to the need of web content processing, such as modifying the image path to a local path, then this modified web content stored locally, open the local web use WebView.
Reply:
cited a floor reply:
first get to the page content, according to web content needs to be processed, such as modifying the image path to a local path, then this Web content is stored locally modified, open the local web use WebView.

Khan, but also greatly you, ah, said this method to die, I have changed the way the question, ah, how to answer or did not change one word - | | embarrassing
Reply:
Landlord, this is a classic approach, but also the practice of most browsers.

Maybe you think it will be easier to change the framework, maybe you think Android than iPhone compatibility okay.

Well,
Reply:
reference to the third floor of the reply:
landlord, this is a classic approach, but also the practice of most browsers.

Maybe you think it will be easier to change the framework, maybe you think Android than iPhone compatibility okay.

Well,

I did not mean, not to say that this method does not work, but taking into account the technical, time spent, coding difficulty, which does not fit it, you proposed this method when I tried to catch when the page first error ( I do not know where the problem is, these pages are able to catch Baidu grabbed normal), and then ask a colleague, they say doing so would be very troublesome.
Moreover, even if successful will be saved to a local web page, but certainly not a relative path resources used, there must write an algorithm transforming them all over, but this time they developed this project did not consider this (because they were against the development ios web games, android is not familiar with, so consider replacing ios image resources can be achieved, android certainly can), so the pages js, css, images, and hyperlinks, etc., etc. Some of them are written by the server relative path, some are write absolute path, in short, very confusing, to write an algorithm to replace all of these labels path, at least, I now feel in their own ability, it is difficult to complete. (This game ported only takes 1-2 days to complete, if caught pages, I do not know what to get for a long time)
So, I would like to ask, are there any other ways - | | 2.2 also provides an interface for example, but I did not find, or rewrite a component or class can be done, and so, I want to know, there is no such possibility
Reply:
You find out there is no separate extraction kits, learn next. .
Reply:
The landlord, ask your WebViewClient under the shouldInterceptRequest (WebView view, String url) method of how to manually replace webView resources? ? ?
Reply:
Landlord this issue is resolved yet, I also encountered the same problem

No comments:

Post a Comment