This shows you the differences between two versions of the page.
sample_code:battery_level [2016/07/23 10:21] titus Battery Level |
sample_code:battery_level [2016/08/29 14:16] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Battery Level** | ||
- | |||
- | This is a simple app that displays battery level and also notifies it on the notification bar. | ||
- | |||
- | <code JavaScript> | ||
- | |||
- | // | ||
- | function OnStart() | ||
- | { | ||
- | app.SetDebugEnabled(false) | ||
- | // | ||
- | lay = app.CreateLayout( " | ||
- | batt = app.GetBatteryLevel() | ||
- | bat = batt*100+" | ||
- | // | ||
- | if(batt< | ||
- | else if(batt< | ||
- | else if(batt< | ||
- | else{ lay.SetBackColor("# | ||
- | // | ||
- | txt = app.CreateText( bat ); | ||
- | txt.SetTextSize( 45 ); | ||
- | lay.AddChild( txt ); | ||
- | setInterval(" | ||
- | // | ||
- | app.AddLayout( lay ); | ||
- | |||
- | |||
- | // | ||
- | notify1 = app.CreateNotification(); | ||
- | notify1.SetMessage( " | ||
- | notify1.SetLights( "# | ||
- | notify1.Notify() | ||
- | |||
- | } | ||
- | function battery(){ | ||
- | batt = app.GetBatteryLevel() | ||
- | bat = batt*100+" | ||
- | txt.SetText(bat) | ||
- | notify1.SetMessage( " | ||
- | notify1.Notify() | ||
- | } | ||
- | </ | ||
- | |||