Is there a limit on url length in Android method WebView.loadUrl?

I want to "transfer" local resources to a page downloaded from a remote server.

I want to do something like this:

webView.loadUrl('http://my.server.com/page.html');
webView.loadUrl('javascript:function someLong(){}function codeHere(){}....');

This is to save bandwidth and reduce load times.

As I can see, resource files cannot be downloaded from a remote web page ...

+4
source share
3 answers

It seems that there is no limit or it is very large. I did some tests with simple code

webView.loadUrl(
    "javascript:function a(s){alert(s.length + ' ' + s.substring(s.length-5))}");
String repeated = 
    String.format(String.format("%%0%dd", 80000), 0).replace("0", ".") + "xx";
webView.loadUrl("javascript:a('"+repeated+"')");

The first line: the definition of the function, the second line - the preparation of a long line, the third - a call function with a very long string argument.

It works great. As a result, I see a warning to JS: "80002 ... xx"

+3
source

webView.loadUrl("javascript:wave()"); JS, HTML-. , webView.loadData() webView.loadDataWithBaseURL()? ?

+1

By default, loadURL makes a receive request, which has a limit of 254 characters. That is why the problem.

0
source

All Articles