简体   繁体   中英

How to improve Webview performence in Android?

I am developing an app in android using WebView. My HTML page is coming from the GAE server. The page contains a lot oh high resolution images, is there a way to store and reference those images from the assets folder, or reference local images. That will help me increase the performance. I would want to keep the HTML on the server and not make it local.

First, you cannot store images in the assets folder programatically. Second, the problem is with your images. If you're developing for a smartphone, it would make no sense to use high-res images with the app. If you have control over your server, do that. Otherwise, there's nothing you can do.

Why don't you put your image in drawable?

If you put your image in assets, then you can load it by the code:

String str = "\assets\resName";
InputStream is = getClass().getResourceAsStream(str);
Bitmap bitmap = BitmapFactory.decodeStream(is);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM