At present, for mobile, desktop-based native development platforms have their own development language, development tools and so on. If we are going to develop a system that fits multiple terminals, we need to develop separate applications using our own platform tools, which is very demanding and time-consuming for a team or a developer. The bootstrap framework was studied in the previous article, and there was a solution for multi-terminal interface adaptation. But in addition to interacting with users, a system may also need to interact with the hardware to implement certain special needs, such as camera invocation, album acquisition, etc. For these hardware calls we can choose PhoneGap.
Introduction PhoneGap is a framework for hardware interaction with multiple terminals, the version I use is phonegap-2.9.0, supported platforms are Android,blackberry,ios,tizen,winphone7 and 8,WIN8. Of course, the platforms supported by a particular feature may vary, depending on the official documentation. PhoneGap's official website is http://phonegap.com/. For different platform support, need to set up a different initial environment, such as Android need to import the relevant jar package, configure the initial XML, once these environments are configured, multiple platforms can access the same HTML or dynamic Web pages to achieve hardware interaction with each platform.
Environment Construction official website Download phonegap-2.9.0, I was downloaded by manual download zip, unzip. The platform used for this example is Android, and other platforms are built similar. Examples provided by the generals Net
.. \phonegap-2.9.0\lib\android\exampleImport to eclipse. You can see that the project structure is as follows: where assets holds the JS code that actually calls the hardware, config file. The class library that introduces the hardware call can be configured through CONFIG. *, the initial access path of the program.
Instance
.. \phonegap-2.9.0\doc contains examples of various APIs from PhoneGap, which can be referenced in this document.
For example, you need to call the Android camera via JS, the steps need to be as follows: 1.androidmanifest.xml Configure access rights
<uses-permission android:name= "Android.permission.CAMERA"/>
2.config.xml Introducing Class Libraries
<feature name= "Camera" > <param name= "android-package" value= "Org.apache.cordova.CameraLauncher"/> </feature>
3. The actual JS call
Summary if you need to apply PHONEGAP to develop the system, the premise must be to configure the basic environment for each target platform. Once the underlying environment is available, unified code development is possible. Due to the cross-platform framework and cross-language calls, the performance of PHONEGAP-developed applications is still a gap from native applications, but for common applications, normal hardware can largely ignore this gap.
Web multi-terminal Development Learning Series (II)---Hardware interactive framework phonegap Learning