PhoneGap: Build a cross-platform APP: phoneGap mobile APP practice, serialization 1 (API in PhoneGap ),

Source: Internet
Author: User

PhoneGap: Build a cross-platform APP: phoneGap mobile APP practice, serialization 1 (API in PhoneGap ),

Previously, Benbo serialized the book "Building a cross-platform APP: jQuery Mobile APP practice", which is favored by beginners of Mobile development.

From now on, the book phoneGap, its twin sister book, has become a big white book.

3.6 what can APIs in PhoneGap do?

This chapter mainly introduces the preparations required before the development of PhoneGap. Do you want to talk about PhoneGap now? In fact, PhoneGap is used to display pages written in HTML and obtain several groups of data through specific JavaScript.

Although the use of PhoneGap for development mainly relies on the knowledge of HTML, for a PhoneGap developer, the most important thing is the usage of various APIs of PhoneGap. PhoneGap provides developers with battery status, cameras, contacts, file systems, audio, and other API interfaces. This section describes their functions and functions.

1. Accelerometer (acceleration sensor)

Accelerometer is usually the gravity sensor in people's mouth. It can be used to obtain the acceleration in all directions of the mobile phone. For example, you can use the feature that the gravity acceleration is about 10 to get the direction of the current mobile phone, in some games, you can use it and some algorithms to perform somatosensory operations (for example, simulating users' operations on the steering wheel ).

2. Camera (Camera)

Camera, as it literally means, can be used to obtain the information collected by the Camera, but it is generally not very useful.

3. Capture (collection tool)

Capture is similar to a recorder or video recorder. It can be used to record audio videos or Capture images and upload them to the network. It can also be used to obtain multimedia information from the network. Capture is used in some social applications. For example, Renren's image upload function can be implemented simply by using it.

4. Compass (Compass)

If the accelerometer is used to sense gravity and know the direction of the ground, then the compass can obtain the direction between East and West, it can be used with the acceleration sensor and geographic location sensor to implement some amazing functions, such as knowing the user's location from the photos that the user is currently taking.

This sounds mysterious, but it is not impossible. For example, the information obtained from the geographic location sensor indicates that the user is on the beach; the compass can prove that the user is facing the sea; you can even determine the content of a user's photo without analyzing the photo.

5. Connection)

The connection is only used to determine the network status of a user.

6. Contts (contact)

Contts adds, deletes, modifies, and queries contacts on a device. It is a very useful set of APIs.

7. Device (get Device information)

Device can obtain the version number, operating system, and other information of the Device.

8. Events (system Events)

Events is a callback function that responds to system time. For example, if a user sends a notification when the power usage is too low, the user can also respond to functions such as the volume key or search key.

9. File (File Management System)

Files can be used to manage files on mobile phones. However, due to the execution efficiency of PhoneGap, it is not recommended that you use it to develop a File manager or even a simple e-book reader. In the application, you can use File to perform some simple operations on the File (for example, saving some messages or notes in the txt File.

10. Geolocation (geographic location sensor)

Geolocation is what users call GPS. It is a commonly used function in social media software and is usually used with other sensors.

11. Media)

Media is used to record and play audio files. It is not as useful as a collection tool.

12. Notification (Reminder)

Notification can call functions such as device vibration and buzzer, which are generally used to provide feedback on user operations. For example, a series of vibrations are triggered when a user crashes in a game.

13. Storage (Local Storage)

Storage is a very useful set of APIs. You can use simple database functions locally and cache some news or chat records in actual development.

Phonegap is getting more and more available, and the entry threshold is low. You can write less code to generate a friendly mobile interface. Build a cross-platform APP: Phonegap mobile APP practice this book introduces APP development under Phonegap in an instance-driven manner. The book provides more than 20 practical cases to teach readers to carry out mobile development, at last, we also reviewed and consolidated the knowledge points through three small projects.

The android program built by phonegap cannot use JS when accessing web pages.

What do you mean by "a local web environment" refers to the site configured for release on your pc or under the phonegap directory? How do you bind your own JavaScript code to controls? Although phonegap is a website shelling, some native response events may be different from those on pc sites. also, you must first determine if your js has a problem in the phonegap environment. You can use the eclipse logcat for debugging.

Now I am going to use PhoneGap to develop the app. Do I have to re-write the code on Xcode before? Can I use PhoneGap to import the code?

Yes! I used OC in the past. Now I have to write HTML5 in different languages, but I just thought the same way. It basically needs to be rewritten.
Hope to help you.

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: 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.