[ 
https://issues.apache.org/jira/browse/CB-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13185600#comment-13185600
 ] 

Raymond Camden commented on CB-173:
-----------------------------------

This is not a bug with the functionality, but rather a doc bug. The docs do not 
mention that you need to add this to your plugins.xml file:


    <plugin name="Battery" value="com.phonegap.BatteryListener"/>


                
> Battery events not working properly on HTC Inspire running 2.2
> --------------------------------------------------------------
>
>                 Key: CB-173
>                 URL: https://issues.apache.org/jira/browse/CB-173
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 1.3.0
>         Environment: HTC Inspire, Android 2.2
>            Reporter: Filip Maj
>
> Originally reported by Ray Camden:
> Trying to get a very simple battery status app working. None of my events 
> ever fire. According to the docs, batterystatus should fire when 
> plugging/unplugging a device, but that doesn't trigger it either. Any ideas? 
> HTC Inspire, Android 2.2 SDK. Code below. Note the alert in my battery status 
> callback. I did that in case I screwed up something simple in drawStatus.
> <!DOCTYPE HTML>
> <html>
>   <head>
>     <meta name="viewport" content="width=320; user-scalable=no" />
>     <meta http-equiv="Content-type" content="text/html; charset=utf-8">
>     <title>Minimal AppLaud App</title>
>         <script type="text/javascript" charset="utf-8" 
> src="phonegap-1.3.0.js"></script>
>         <script type="text/javascript" charset="utf-8">
>               var status;
>               var drawStatus = function(info){
>                       var s = "<p><b>Battery Status</b><br/>";
>                       s += "Level is "+info.level + "<br/>";
>                       s += "Plugged in is "+info.isPlugged;
>                       s += "</p>";
>                       status.innerHTML = s;
>               };
>                               
>               var battCrit = function(info) {
>                       navigator.notification.alert("Your battery is SUPER 
> low!");
>                       drawStatus(info);
>               };
>               var battLow = function(info) {
>                       navigator.notification.alert("Your battery is low!");
>                       drawStatus(info);
>               };
>               var battStat = function(info) {
>                       alert('test');
>                       drawStatus(info);
>               };
>         
>         var onDeviceReady = function() {
>                       //listen for battery crit
>                       window.addEventListener("batterycritical", battCrit, 
> false);
>                       window.addEventListener("batterylow", battLow, false);
>                       window.addEventListener("batterystatus", battStat, 
> false);
>                       alert("registered...");
>         };
>         function init() {
>             document.addEventListener("deviceready", onDeviceReady, true);
>                       status = document.getElementById("status");
>         }   
>         </script>  
>   </head>
>   <body onload="init();">
>     <h2>Battery Tester</h2>
>       <div id="status"></div>
>   </body>
> </html>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to