Cordova Tutorial
Cordova Useful Resources
Selected Reading
- Cordova - Best Practices
- Cordova - Whitelist
- Cordova - Vibration
- Cordova - Splash Screen
- Cordova - Network Information
- Cordova - Media Capture
- Cordova - Media
- Cordova - InAppBrowser
- Cordova - Globalization
- Cordova - Geolocation
- Cordova - File Transfer
- Cordova - File System
- Cordova - Dialogs
- Cordova - Device Orientation
- Cordova - Accelerometer
- Cordova - Device
- Cordova - Contacts
- Cordova - Camera
- Cordova - Battery Status
- Cordova - Plugman
- Cordova - Back Button
- Cordova - Events
- Cordova - Storage
- Cordova - Config.xml File
- Cordova - First Application
- Cordova - Environment Setup
- Cordova - Overview
- Cordova - Home
Cordova Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Cordova - Device
Cordova - Device
This plugin is used for getting information about the user’s device.
Step 1 - Instalpng Device Plugin
To install this plugin, we need to run the following snippet in the command prompt.
C:UsersusernameDesktopCordovaProject>cordova plugin add cordova-plugin-device
Step 2 - Adding Button
We will be using this plugin the same way we used the other Cordova plugins. Let us add a button in the index.html file. This button will be used for getting information about the device.
<button id = "cordovaDevice">CORDOVA DEVICE</button>
Step 3 - Adding Event Listener
Cordova plugins are available after the deviceready event so we will place the event pstener inside the onDeviceReady function in index.js.
document.getElementById("cordovaDevice").addEventListener("cpck", cordovaDevice);
Step 4 - Creating Function
The following function will show how to use all possibipties the plugin provides. We will place it in index.js.
function cordovaDevice() { alert("Cordova version: " + device.cordova + " " + "Device model: " + device.model + " " + "Device platform: " + device.platform + " " + "Device UUID: " + device.uuid + " " + "Device version: " + device.version); }
When we cpck the CORDOVA DEVICE button, the alert will display the Cordova version, device model, platform, UUID and device version.
Advertisements