开发者

Using JavaScript in Android - will it slowdown activity?

开发者 https://www.devze.com 2023-04-07 13:04 出处:网络
H开发者_运维百科ello I what to make a small app for Android 2.2 that will display a chart with data that I\'ll get from an API. I didn\'t find a free library for Android that can draw the chart like I

H开发者_运维百科ello I what to make a small app for Android 2.2 that will display a chart with data that I'll get from an API. I didn't find a free library for Android that can draw the chart like I want and I was thinking to use a WebView to load a local HTML and then use a JavaScript library to draw my chart.

Is this a good solution or will this create other problems? In the same activity I will have a panel similar to the SlidingDrawer and I am concerned that the calls to my WebView to render the chart will slow down my app.

Thanks for suggestions/advice.


I am currently using WebView extensively in Android. While we have done a great deal with it and it generally works, I have noticed some problems with missing touch events when using Canvas inside of a WebView (see How can I prevent performance degradation for Canvas inside of WebView on an Android Xoom?).

My personal advice to you would be to implement the drawing that you want natively. Then if you want to add interactivity, you will benefit from better performance and reliability than through WebView. I'm not sure how the JavaScript library you want to use draws your chart or what your future plans are. For example, if you're going to need WebView and JavaScript for other features, you might as well try it out now and start learning all the details of WebViews. I would search SO for questions related to Android WebView before committing so you have an idea of how much work you are adding so you can "save time" by using a JavaScript library.

My opinion. Hope it's helpful.

0

精彩评论

暂无评论...
验证码 换一张
取 消