Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:How to create a battery widget using Flash Lite (WRT)

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

Article Metadata
Code ExampleCompatibility
S60 5th Edition
Created: raheal_akh (31 May 2008)
Last edited: hamishwillee (14 May 2013)



Flash Lite Code


var talktime:Number;
var standbytime:Number;
device_name_txt = "N95";
//Get Instant Battery Check
// Monitor Battery level after certain time elapse to
// call the function to show batter status on the screen.
// Set Interval in miliseconds
setInterval(batteryFunc, 5000); //5 Seconds
//Battery func fetches the battery level and displays it on the screen
function batteryFunc(){
batMax = fscommand2("GetMaxBatteryLevel");
batLevel = fscommand2("GetBatteryLevel");
batSource = fscommand2("GetPowerSource");
//Change the battery_lvl_mc height depending on the Battery Level
_root.battery_mc.battery_lvl_mc._height = Math.ceil(batLevel*100/batMax);

Determining Battery life and standby time

Remaining Battery time and standby time can simply be known by the targeted device specifications. hence using a simple mathematical formula, results can be quickly known

//Show Battery text
//N95 - standard talk time is 6.5 Hours and Standby time is 220 Hours
battery_Txt = "Battery Level: " add Math.ceil(batLevel*100/batMax) add "%";
Talk_time_Txt = Math.round(batLevel*390/batMax) add " mins" ; //N95 6.5 Hours
stand_by_time_Txt = Math.ceil(batLevel*220/batMax) add " hr"; //N95 220 Hours
//Change Display status based on battery source
if (batSource == 0) { //On Battery
//Change Display status
else if (batSource == 1) { //On Charger
else { //Unknown

device specifications for some of the nokia mobile phones

//Determine Device talk time and standby time based on the Phone Specifications taken from Nokia Website
statusdevice = fscommand2("GetDevice", "devicename");
switch(devicename) {
case "Nokia N95":
device_name_txt = "N95";
talktime = 390; //6.5 hours
standbytime = 220; //220 Hours
case "Nokia 5300":
device_name_txt = "5300";
talktime = 192; //3.2 hours
standbytime = 223; //220 Hours
case "Nokia 6290":
device_name_txt = "6290";
talktime = 210; //3.5 hours
standbytime = 260; //260 Hours
case "Nokia 6300":
device_name_txt = "6300";
talktime = 210; //3.5 hours
standbytime = 348; //348 Hours
case "Nokia 7390":
device_name_txt = "7390";
talktime = 190; //3 hours
standbytime = 220; //220 Hours
case "Nokia 3250":
device_name_txt = "3250";
talktime = 210; //3.5 hours
standbytime = 245; //245 Hours

Final Output



Download source code


How to Package Flash content in a Widget

--raheal_akh 00:14, 1 June 2008 (EEST) RAHEAL AKHTAR

This page was last modified on 14 May 2013, at 06:22.
44 page views in the last 30 days.