官术网_书友最值得收藏!

Overview of Cordova APIs

Currently, Apache Cordova supports the following mobile native functions APIs:

  • Accelerometer: This allows you to capture the device motion in all directions (x, y, and z)
  • Camera: This allows you to use the default camera application in order to capture photos
  • Capture: This allows you to capture audio using the device's audio recording application, capture images using the device's camera application, and capture video using the device's video recording application
  • Compass: This allows you to get the direction that the device is pointing to
  • Connection: This provides you with the information about the device's cellular and Wi-Fi connection
  • Contacts: This allows you to access the device's contacts database, create new contacts in the contacts list, and query the existing device contacts list
  • Device: This allows you to get the hardware and software information of the device; for example, it allows you to get the device model, receive the platform and its version, and finally, receive the device name
  • Events: This allows you to listen and create handlers for Apache Cordova life cycle events. These life cycle events are as follows:
    • deviceready: This event fires once Apache Cordova is fully loaded
    • pause: This event fires if the application is put into the background
    • resume: This event fires if the application is resumed from the background
    • online: This event fires if the application becomes connected to the Internet
    • offline: This event fires if the application becomes disconnected from the Internet
    • backbutton: This event fires if the user clicks the device's back button (some mobile devices have a back button, such as Android and Windows Phone devices)
    • batterycritical: This event fires if the device's battery power reaches a critical state (that is, reaches the critical-level threshold)
    • batterylow: This event fires if the device battery power reaches the low-level threshold
    • batterystatus: This event fires if there is a change in the battery status
    • menubutton: This event fires if the user presses the device's menu button (the menu button is popular for Android and BlackBerry devices)
    • searchbutton: This event fires if the user presses the device's search button (the search button can be found in Android devices)
    • startcallbutton: This event fires when the user presses the start and end call buttons of the device
    • endcallbutton: This event fires when the user presses the start and end call buttons of the device
    • volumeupbutton: This event fires when the user presses the volume up and down buttons of the device
    • volumedownbutton: This event fires when the user presses the volume up and down buttons of the device
  • File: This allows you to process files (which is to read, write, and navigate filesystem directories), and it is based on the W3C file APIs
  • Geolocation: This allows you to receive the device's location using GPS or using network signals, and it is based on W3C geolocation APIs
  • Globalization: This allows you to get the user's locale and perform locale-specific operations
  • InAppBrowser: This represents a web browser view that is displayed when any call to window.open() or a link whose target is set to "_blank" is clicked
  • Media: This allows for the recording of audio files programmatically, without using the device default recording application, as well as playing audio files
  • Notification: This allows the display of audible notifications such as beeps, the display of tactile notifications such as vibrations, and displaying visual notifications such as the normal device visual messages to the user
  • Splashscreen: This allows you to display application splash screen
  • Storage: Apache Cordova provides the following storage capabilities:
    • Using the W3C web storage interface which is about LocalStorage and SessionStorage. It is important to know that local storage is a permanent storage that exists on your device even if your application is closed, while session storage is a temporary storage that is erased when the user session ends, which is when the application is closed.
    • Using the full features of relational databases by supporting Web SQL on almost all the platforms. For Windows Phone and Windows Platform, it supports IndexedDB, which is currently a W3C standard.

Tip

Although Web SQL is deprecated, it was and still is a powerful specification for creating and working with relational data.

All of these APIs will be illustrated in far more detail, along with examples, as you read this book. It is important to note that not all of these APIs are supported in all the platforms. You will be able to specifically check which ones are not supported in the following list. Also note that this list applies to Apache Cordova Version 3.4, and it might be changed later. The following table shows the unsupported APIs on the different platforms. Please note that X here means unsupported:

主站蜘蛛池模板: 遵义县| 思茅市| 禄丰县| 三原县| 漳浦县| 南投县| 锦州市| 江门市| 台湾省| 金溪县| 漯河市| 梁河县| 新和县| 于都县| 贺州市| 会理县| 子洲县| 夏河县| 阿克苏市| 镇远县| 仁怀市| 祁东县| 延津县| 闸北区| 左云县| 曲麻莱县| 镇坪县| 庐江县| 松阳县| 禄丰县| 荣成市| 综艺| 惠来县| 广西| 祁连县| 古丈县| 元氏县| 龙州县| 凉山| 电白县| 辽宁省|