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
Because I am not familiar with Facebook's adv...
[[417771]] Language Transfer is an open source la...
Zhihu itself is very averse to others doing marke...
Training course content: Women are always trapped...
Recently, I have been busy communicating with dif...
Google Search has more than 80% market share in t...
In 2021, the launch and growth teams of overseas ...
We always think that we have enough knowledge and...
Recently, some people have been asking, “Why is T...
When building a website, there will always be som...
1. Short video-live broadcast room resonance When...
Maybe you've never written a bad line of code...
Zhang Qi: Digging for gold from traffic and explo...
Are you still worried about having nowhere to dis...
[[122276]] In light of recent hacker attacks, the...