Android : Slow loading local HTML file android

on Monday, September 15, 2014


I am loading a html from the assets folder. It is positioned below an image-view. The code works, however it takes a second for the html file to appear on the device.


here is the code:



public class FgmIsChildAbuse extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.webview);

WebView mWebView;
mWebView = (WebView) findViewById(R.id.webviewm1);

WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

mWebView.loadUrl("file:///android_asset/m1_section1_read.html");

ImageView ImageView1 = (ImageView) findViewById(R.id.ImageView1);

Resources res = getResources(); /** from an Activity */

ImageView1.setImageDrawable(res.getDrawable(R.drawable.images_eyes));

mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);

mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);


}


}

0 comments:

Post a Comment