/***
* 获取手机电量
*/
function getPhoneBattery(){
var main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass('android.content.Intent');
var recevier = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: function(context, intent) {
var action = intent.getAction();
if (action == Intent.ACTION_BATTERY_CHANGED) {
var level = intent.getIntExtra("level", 0); //电量
var voltage = intent.getIntExtra("voltage", 0); //电池电压
var temperature = intent.getIntExtra("temperature", 0); //电池温度
console.log(level);
Battery=level;
}
}
});
* 获取手机电量
*/
function getPhoneBattery(){
var main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass('android.content.Intent');
var recevier = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: function(context, intent) {
var action = intent.getAction();
if (action == Intent.ACTION_BATTERY_CHANGED) {
var level = intent.getIntExtra("level", 0); //电量
var voltage = intent.getIntExtra("voltage", 0); //电池电压
var temperature = intent.getIntExtra("temperature", 0); //电池温度
console.log(level);
Battery=level;
}
}
});