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
With the popularity of the smart home concept, to...
Novels have become an indispensable part of our li...
In 2014, the mobile smart terminal market was ful...
The price of iPhone is not cheap, so what about it...
There are too many "have to" in life I ...
Two days ago, the 2016 MacBook Pro was released, w...
What is the price of Lianyungang mobile phone acc...
Since the beginning of 2021, my country's con...
As the number of incremental Internet users decre...
The media’s algorithm is a black core. We don’t k...
Batteries are indispensable in our daily lives, b...
What is Spider Pool? Spider Pool is a hacker prog...
2016 was the year when fast-charging mobile phone...
There is new news about Musk’s brain-computer int...