Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

New Developer
Posts: 70
Registered: ‎01-13-2011
My Device: Torch 9800 and Playbook
My Carrier: Rogers

When the Battery Low Dialog Shows, Does My Playbook Webworks app Receive the toBackground Action

I'm assuming there's a modal dialog that shows up when the battery is low. Is my app somehow automatically paused when this happens? Or can I respond to a toBackground event? I'd need to pause a game loop.

Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: When the Battery Low Dialog Shows, Does My Playbook Webworks app Receive the toBackground Action

When the battery level is low, the Tablet OS initates a system event.  There is no modal dialog window, however there is a battery icon in the system tray.


From your WebWorks application, you can listen to the battery level system event, and respond accordingly (such as pausing or suspending your application if you determine the battery is at a critically low level).


Here's a sample that demonstrates how to use the battery system event from within a WebWorks application:\



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
<script type="text/javascript">
   function handleBatteryLevel(level)
      var ele = document.getElementById("batteryLevel");
      if (ele)
         ele.innerHTML = "Battery Level: " + level;
      document.getElementById("level").style.width = level + "%";
   function setHandlers()
<style type="text/css">
		border: solid 1px black;
		background-color: white;
		clear: both;
		background-color: lime;
		display: block;

<body onload="setTimeout(setHandlers, 1000)">
<h1>System Event API</h1>

<div class="demo">
	<div id="batteryLevel"></div>
	<div class="batteryLevelBar">
		<div id="level" class="batteryLevel">&nbsp;</div>






Follow me on Twitter: @n_adam_stanley
Your app doesn't work? Use BlackBerry remote web inspector to find out why.