I am working on a webView in an app, where content which webview load changes when a button is pressed (two buttons next and previous , they just change the content in webview). But after pressing 3 -4 times it starts to hang there is nothing printed on logcat, the button remains pressed for 15-20 sec and then the next data is loaded.
I have used these to clear out webview.db and cache:-
context.this.deleteDatabase("webview.db");
context.this.deleteDatabase("webviewCache.db");
webView.getSettings().setRenderPriority(RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
But still it hangs.How can I speed it up?Please help?
UPDATED:
public void setWebView(String QuestionParent,String QuestionNumber)
{
WebSettings webSettings = questionWeb.getSettings();
webSettings.setDefaultFontSize(24);
questionWeb.getSettings().setRenderPriority(RenderPriority.HIGH);
questionWeb.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
questionWeb.loadDataWithBaseURL("",integralParse.htmlParse(questionCode,"mnt/sdcard/faData/"+QuestionParent+"/"+QuestionNumber),"text/html","UTF-8","");
}
I am using this method on button press. integralParse.htmlParse() method returns a html text .
Are you handling webView navigation properly? See this tutorial on the official docs:
https://developer.android.com/guide/webapps/webview.html#HandlingNavigation
if you are just using loadData() then you can try setting hardware acceleration on in the manifest file like this:
add it at the application level, i.e in the tag of your AndroidManifest.xml file
After this point, it really depends on your device. If you have a high end device, images will be rendered quickly otherwise they will take time since webView is using webkit hardware acceleration and this depends on your device configuration.
if you still need speed, you can try making a fully native app without webview. Everything will be smooth as butter. No webkit, no html and much greater control.
Good luck :-)