<plugin name="Battery" value="org.apache.cordova.BatteryListener" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<key>Plugins</key> <dict> <key>Battery</key> <string>CDVBattery</string> </dict>
document.addEventListener("deviceready", yourCallbackFunction, false);
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { // Now safe to use the Cordova API }
document.addEventListener("pause", yourCallbackFunction, false);
document.addEventListener("pause", onPause, false); function onPause() { // Handle the pause event }
document.addEventListener("resume", yourCallbackFunction, false);
document.addEventListener("resume", onResume, false); function onResume() { // Handle the resume event }
document.addEventListener("online", yourCallbackFunction, false);
document.addEventListener("online", onOnline, false); function onOnline() { // Handle the online event }
ocument.addEventListener("offline", yourCallbackFunction, false);
document.addEventListener("offline", onOffline, false); function onOffline() { // Handle the offline event }
document.addEventListener("backbutton", yourCallbackFunction, false);
document.addEventListener("backbutton", onBackKeyDown, false); function onBackKeyDown() { // Handle the back button }
window.addEventListener("batterycritical", yourCallbackFunction, false);
window.addEventListener("batterycritical", onBatteryCritical, false); function onBatteryCritical(info) { // Handle the battery critical event alert("Battery Level Critical " + info.level + "%\nRecharge Soon!"); }
window.addEventListener("batterylow", yourCallbackFunction, false);
window.addEventListener("batterylow", onBatteryLow, false); function onBatteryLow(info) { // Handle the battery low event alert("Battery Level Low " + info.level + "%"); }
window.addEventListener("batterystatus", yourCallbackFunction, false);
window.addEventListener("batterystatus", onBatteryStatus, false); function onBatteryStatus(info) { // Handle the online event console.log("Level: " + info.level + " isPlugged: " + info.isPlugged); }
document.addEventListener("menubutton", yourCallbackFunction, false);
* Quick Example
document.addEventListener("menubutton", onMenuKeyDown, false); function onMenuKeyDown() { // Handle the back button }
document.addEventListener("searchbutton", yourCallbackFunction, false);
* Quick Example
document.addEventListener("searchbutton", onSearchKeyDown, false); function onSearchKeyDown() { // Handle the search button }
document.addEventListener("startcallbutton", yourCallbackFunction, false);
* Quick Example
document.addEventListener("startcallbutton", onStartCallKeyDown, false); function onStartCallKeyDown() { // Handle the start call button }
document.addEventListener("endcallbutton", yourCallbackFunction, false);
* Quick Example
document.addEventListener("endcallbutton", onEndCallKeyDown, false); function onEndCallKeyDown() { // Handle the end call button }
document.addEventListener("volumedownbutton", yourCallbackFunction, false);
* Quick Example
document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false); function onVolumeDownKeyDown() { // Handle the volume down button }
document.addEventListener("volumeupbutton", yourCallbackFunction, false);
* Quick Example
document.addEventListener("volumeupbutton", onVolumeUpKeyDown, false); function onVolumeUpKeyDown() { // Handle the volume up button }