Cordova(PhoneGap)-已调用batterystatus-callback,但根据登录记录,状态和被插入均为未定义
可能是什么原因?
onDeviceReady: function() {
//alert('deviceready!!!!!!!!');
d.lg('device ready :-)');
window.addEventListener('batterystatus', app.batteryListener, false);
app.receivedEvent('deviceready');
},
batteryListener: function() {
//alert("batterylistener!");
console.log("Level: " + status.level + " isPlugged: " + status.isPlugged);
}
logcat AndroidStudio
2019-04-05 15:38:36.039 17689-17689/com.phonegap.app D/SystemWebChromeClient: file:///android_asset/www/js/app.js: Line 93 : Level: undefined isPlugged: undefined
2019-04-05 15:38:36.039 17689-17689/com.phonegap.app I/chromium: [INFO:CONSOLE(93)] "Level: undefined isPlugged: undefined", source: file:///android_asset/www/js/app.js (93)
答案 0 :(得分:1)
那是因为您的batterListener
方法缺少status
。
batteryListener: function(status) {