PhoneGap "Building cross-platform App:phonegap mobile app" Serial Five (using PHONEGAP to get device information)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.