Hybrid App is the abbreviation of hybrid mode application, which has the advantages of both Native App and Web App, with low development cost and cross-platform characteristics of Web technology. Currently, all the middleware-based mobile development frameworks we know of adopt the Hybrid development model, such as PhoneGap , Titanium, Sencha from abroad, and AppCan, Rexsee, etc. from China. The Hybrid App development model is being recognized by more and more companies and developers, and I believe it will become the mainstream mobile application development model in the future. The principle of Hybrid App fusion Web App is to embed a WebView component, in which you can load pages, which is equivalent to an embedded browser. The code is as follows:
Another way to introduce it is to add the WebView component in the layout file. The code is as follows:
WebView also has a very important method - addJavascriptInterface, which can be used to implement mutual calls between Java programs and JavaScript programs. The code is as follows:
The page code is as follows:
In this way, when you click the Click Me button on the page, the clickOnAndroid function in the Java code will be called, and the clickOnAndroid function will call the wave method in the page. It should be noted that this interface will cause WebView to crash when running in the Android 2.3 version of the emulator, and it has not been fixed yet. This is a very simple example of demonstrating the mutual calls between Java and JavaScript. In actual applications, the clickOnAndroid function called by the page can call device functions such as camera, address book, notification reminder, etc. |
<<: Tingyun CTO: AWS and Tingyun join hands to create a domestic cloud + APM model
>>: Frameworks and tools that hybrid app developers must not miss
Recently, new cases have appeared in Jilin, Changc...
As the new media director of Fan Deng Reading, I ...
Many friends who need ghostwriting for copywritin...
Let me first tell you a real case we received: Xi...
In 2014, as relevant state departments relaxed re...
The Internet is a very magical world. As long as ...
Leviathan Press: Few people would say that they l...
Ling'er Investment Research Diary "T+0 Pr...
In recent years, news about "cardiac arrest&...
1 Behind the TikTok phenomenon As of mid-June 201...
According to the recently revised "Beijing A...
Build a community that can sell goods and make mo...
Previously, the topic #Microplastics in takeout c...
Microsoft made several big announcements recently...
Leviathan Press: I personally think Walter Schere...