Li Che
Li Che

Reputation: 737

Android webview apply start too slowly.

I created an android application. It uses a WebView to upload local html. But it starts very slowly. It uploads the page in about 10 seconds. Why it is so slow? What method can let the application starts faster?

Upvotes: 5

Views: 7131

Answers (3)

Nikhil Gaur
Nikhil Gaur

Reputation: 1272

Apart from above do you also have all the external static resource locally in your app?

This is a common problem users used to load HTML content locally but its resources like JS, CSS, Fonts etc are referenced on some http URL. Apart from the Darpan's solution above you can also store your resource locally to make it even faster.

Here are the details instructions to do so.

Upvotes: 0

Darpan
Darpan

Reputation: 5795

Try using this - This will enable cache in your webview thus might help you load pages faster.

 WebSettings webSettings = webview.getSettings();
 webSettings.setPluginsEnabled(true);
 webSettings.setJavaScriptEnabled(true);
 webSettings.setDatabaseEnabled(true);
 webSettings.setDomStorageEnabled(true);
 webSettings.setAppCacheEnabled(true);
 webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

this snippet is for loading any page faster, if you specifically want to load local pages only try using example explained on This Link.

Upvotes: 0

Eldhose M Babu
Eldhose M Babu

Reputation: 14520

Try using a WebViewClient along with the web view and use the overrided method "shouldOverrideUrlLoading" and return accordingly.

Upvotes: 0

Related Questions