User Tools

Site Tools


Privacy Policy


Version 2.50 is out since Jan 1st 2022

Frequently Asked Questions


Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax


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()
    //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
    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 );
    //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 ); 
function battery(){
batt = app.GetBatteryLevel()
    bat = batt*100+"%"
notify1.SetMessage( "Battery Level is " +bat, "Battery Level",bat);

Home»Sample Code

sample_code/battery_level.txt · Last modified: 2016/08/29 14:16 (external edit)