In addition to being able to package HTML pages into an app that can be run directly, PhoneGap has one of the biggest advantages of using JavaScript to invoke devices to access hardware information on the device, which can be achieved only by relying on the native SDK. Sample 5-1 shows an example of using an API to get device information.
"Example 5-1 using PhoneGap for device information"
<! DOCTYPE html>
After compiling with phonegap, run result 5-1 shows.
As you can see in this example, there is no difference between using the API in PhoneGap and using native JavaScript and HTML, just a few pre-defined classes, such as device in line 15th of the example.
PhoneGap defines a class device that contains the 5 member variables of name, PHONEGAP, platform, UUID, version, respectively, the device name of the device, the PhoneGap version number, the operating system, the device number, and the operating system version. Can be referenced directly when used.
The 15th to 19th line of the example uses the innerHTML action to display the information in the device class to the page element, and the page element is obtained using the element's ID attribute on line 13th. Readers familiar with JavaScript can find that this is exactly the same as JavaScript's DOM operations.
Tsinghua University Press launched the "build cross-platform App:phonegap mobile app" is an app book, contains more than 20 app instances and 3 app projects, but also combined with HTML5 mobile development. This book is for mobile development beginners, low threshold, shallow reading, the most suitable for mobile app startup small white. This release of the 3rd to 5th chapter as the basis for readers to learn, interested in the Welcome to buy this book! Welcome Dabigatran:348632872, direct questions to the author of the Exchange!
PhoneGap "Building cross-platform App:phonegap mobile app" Serial Five (using PHONEGAP for device information)