Android and native Integration

Source: Internet
Author: User

Currently, major platforms are competing to launch various eye-catching feature programs. The biggest drawback of HTML5-based development is the inability to enjoy the latest and most dazzling native feature and performance problems. The value of phonegap lies in this, it allows you to enjoy both the cross-platform convenience Based on HTML5 and the native feature. Therefore, we will analyze the phonegap to see how to make HTML5 grow on native.

Analyze the source code of phonegap on the three major platforms (phonegap source code analysis (I) ------ Android and phonegap source code analysis (ii )------
Windows Phone and phonegap source code analysis (3) ------ IOS), we will find that phonegap is based on the webview on various platforms and uses it as a cross-platform Virtual Machine and HTML5 as the bytecode, to build Java on mobile. The so-called native plug-ins actually work hard to package all the features of various platforms. Therefore, the future of the plug-ins is expected at two points, first, various mobile platforms can vigorously develop HTML5 to improve its performance and functions. The second is to keep up with the latest releases of various platforms and include the latest features in the plug-in mode as soon as possible. Therefore, phonegap is not a wonderful framework. It is based on a very simple idea, but it must be done in perfection and detail as much as possible, and the update speed should be faster.

As I mentioned earlier, not all applications are suitable for using phonegap. The key to evaluation is whether the webview can well carry your applications. I have not studied much about this, but from some articles on the Internet, there are problems with the performance of webview. Many people have tested and run the same page on webview and browser, the performance of webview is lower than that of browser, and even if it is no less than browser, browser and native applications cannot be compared. Aside from JS optimization (this is a big topic, the performance loss related to phonegap is mainly as follows:

  • Interaction between JS and Native
  • Differences between html ui and native UI
  • Balance between performance and cross-platform

For the first point, this is actually the most negligible point. Through the analysis of the phonegap source code, the cost of interdebugging between JS and native is not big, in addition to Android's call results, all other calls are direct local method calls, and the interaction between JS and native does not happen every moment.

The gap between html ui and native UI is the most obvious performance issue. This is still the case on the desktop platform, not to mention mobile. Therefore, applications with high UI interaction requirements should focus on whether the gap can be tolerated. I haven't had time to do a deep research on how to improve UI performance and smoothness. Based on the current learning situation, I can do the following:

  • The template technology can be used to separate HTML to avoid a large html.
  • I am not satisfied with Jquery mobile's performance when selecting the most suitable UI framework. I will focus on JQTouch later.
  • Optimize dom render, such as reducing the cost of reflow, http://floatlearning.com/2011/06/the-cost-of-reflows-on-a-web-app/
  • Performance Improvement: small tips, small

The balance between performance and cross-platform is to consider which points need to be put on the native end through plugin. Although the execution performance of JS has been significantly improved in recent years, however, there is still no way to compare it with native. Therefore, if there is a cpu-intensive operation, consider whether it is necessary to sacrifice cross-platform performance to implement blocks on the native end. However, phonegap is a good choice for us. At least we still have a way to go.

Performance optimization is critical for cross-platform mobile development. It cannot be convenient at the cost of user experience. Although it is unlikely to be comparable with native apps, but constantly improving performance is something we can't ignore.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.