cordova - phonegap addEventListener trigger slowly for 2nd time execution -


<script> function onbattery() { window.addeventlistener("batterystatus", onbatterystatus, false); document.getelementbyid('log1').innerhtml+="clicked";        }  function onbatterystatus(info) {  document.getelementbyid('log2').innerhtml+="get"; document.getelementbyid('getbatstatus').innerhtml+="level: " + info.level + " isplugged: "     + info.isplugged; } </script>  <p id="log1">will display log1</p> <p id="log2">will display log2</p> <p id="getbatstatus">will display battery status</p> 

above code display current battery status. on 1st click showing fast. when want run again..it execute slowly... why happen?

the reason why batterystatus event occurs when battery status changes (power level increases, decreases or plug device in)

the first time call onbattery, gives current status waits system raise batterystatus event (could few minutes before change if have string battery)


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -