Battery Level
This is a simple app that displays battery level and also notifies it on the notification bar. Here is the spk.
//Called when application is started. function OnStart() { app.SetDebugEnabled(false) //Create a layout with objects vertically centered. lay = app.CreateLayout( "linear", "VCenter,FillXY" ); batt = app.GetBatteryLevel() bat = batt*100+"%" //Change Color according to battery level if(batt<.1){lay.SetBackColor("#44ff9999")} else if(batt<.5){lay.SetBackColor("#7799ff99") } else if(batt<90){ lay.SetBackColor("#cc9999ff" )} else{ lay.SetBackColor("#ff99ffff")} //Create a text label and add it to layout. txt = app.CreateText( bat ); txt.SetTextSize( 45 ); lay.AddChild( txt ); setInterval("battery()",5000) //Add layout to app. app.AddLayout( lay ); //Notify battery Level notify1 = app.CreateNotification(); notify1.SetMessage( "Battery Level is " +bat, "Battery Level",bat ); notify1.SetLights( "#00ffff", 500, 500 ); notify1.Notify() } function battery(){ batt = app.GetBatteryLevel() bat = batt*100+"%" txt.SetText(bat) notify1.SetMessage( "Battery Level is " +bat, "Battery Level",bat); notify1.Notify() }