목차

Events

설명

제약사항

Android

startcallbutton
endcallbutton
volumedownbutton
volumeupbutto

iOS

pause
online
offline
backbutton
menubutton
searchbutton
startcallbutton
endcallbutton
volumedownbutton
volumeupbutto

환경 설정

Android

<plugin name="Battery" value="org.apache.cordova.BatteryListener" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />

iOS

<key>Plugins</key>
<dict>
    <key>Battery</key>
    <string>CDVBattery</string>
</dict>

이벤트 타입

deviceready

document.addEventListener("deviceready", yourCallbackFunction, false);
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    // Now safe to use the Cordova API
}

pause

document.addEventListener("pause", yourCallbackFunction, false);

document.addEventListener("pause", onPause, false);

function onPause() {
    // Handle the pause event
}

resume

document.addEventListener("resume", yourCallbackFunction, false);

document.addEventListener("resume", onResume, false);

function onResume() {
    // Handle the resume event
}

online

document.addEventListener("online", yourCallbackFunction, false);

document.addEventListener("online", onOnline, false);

function onOnline() {
    // Handle the online event
}

offline

ocument.addEventListener("offline", yourCallbackFunction, false);

document.addEventListener("offline", onOffline, false);

function onOffline() {
    // Handle the offline event
}

backbutton

document.addEventListener("backbutton", yourCallbackFunction, false);

document.addEventListener("backbutton", onBackKeyDown, false);

function onBackKeyDown() {
    // Handle the back button
}

batterycritical

  1. level: battery 잔량의 백분율 (0-100). (Number)
  2. isPlugged: 단말기가 배터리 충전기에 충전되고 있는지의 여부. (Boolean)
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!"); 
}

batterylow

  1. level: battery 잔량의 백분율 (0-100). (Number)
  2. isPlugged: 단말기가 배터리 충전기에 충전되고 있는지의 여부. (Boolean)
window.addEventListener("batterylow", yourCallbackFunction, false);

window.addEventListener("batterylow", onBatteryLow, false);

function onBatteryLow(info) {
    // Handle the battery low event
    alert("Battery Level Low " + info.level + "%"); 
}

batterystatus

  1. level: battery 잔량의 백분율 (0-100). (Number)
  2. isPlugged: 단말기가 배터리 충전기에 충전되고 있는지의 여부. (Boolean)
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); 
}

menubutton

document.addEventListener("menubutton", yourCallbackFunction, false);

* Quick Example

document.addEventListener("menubutton", onMenuKeyDown, false);

function onMenuKeyDown() {
    // Handle the back button
}

searchbutton

document.addEventListener("searchbutton", yourCallbackFunction, false);

* Quick Example

document.addEventListener("searchbutton", onSearchKeyDown, false);

function onSearchKeyDown() {
    // Handle the search button
}

startcallbutton

document.addEventListener("startcallbutton", yourCallbackFunction, false);

* Quick Example

document.addEventListener("startcallbutton", onStartCallKeyDown, false);

function onStartCallKeyDown() {
    // Handle the start call button
}

endcallbutton

document.addEventListener("endcallbutton", yourCallbackFunction, false);

* Quick Example

document.addEventListener("endcallbutton", onEndCallKeyDown, false);

function onEndCallKeyDown() {
    // Handle the end call button
}

volumedownbutton

document.addEventListener("volumedownbutton", yourCallbackFunction, false);

* Quick Example

document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false);

function onVolumeDownKeyDown() {
    // Handle the volume down button
}

voumeupbutton

document.addEventListener("volumeupbutton", yourCallbackFunction, false);

* Quick Example

document.addEventListener("volumeupbutton", onVolumeUpKeyDown, false);

function onVolumeUpKeyDown() {
    // Handle the volume up button
}

파라미터

Objects

참고 자료