//Called when application is created. function OnStart() { app.ShowPopup( "OnStart" ); app.SetMenu( "MyMenu1,MyMenu2" ); app.EnableBackKey( false );      //Get current time in milliseconds.      var now = new Date().getTime();      //Set alarm for 3 seconds time.      app.SetAlarm( "Set", 1234, OnAlarm, now + 3000 ); } //Called when user selects a menu item. function OnMenu( name ) { app.ShowPopup( "OnMenu( " + name + " )" ); } //Called when the back key is pressed. function OnBack() { alert( "OnBack" ); app.Exit(); } //Called when application is paused. //(eg. When user switches to home screen) function OnPause() { app.ShowPopup( "OnPause" ); } //Called when application is resumed. //(eg. When user returns from home screen) function OnResume() { app.ShowPopup( "OnResume" ); } //Called when configuration changes. //(eg. When user rotates phone) function OnConfig() { app.ShowPopup( "OnConfig" ); } //Called when alarm is triggered. //(Even if your app is closed) function OnAlarm( id ) {     app.ShowPopup( "Got Alarm: id = " + id ); } //Handle data sent from other apps. function OnData( isStartUp ) { //Display intent data. var intent = app.GetIntent(); if( intent ) { //Extract main data. var s = "action: " + intent.action + "\n"; s += "type: " + intent.type + "\n"; s += "data: " + intent.data + "\n\n"; //Extract extras. s += "extras:\n"; for( var key in intent.extras ) s += key+": "+intent.extras[key] + "\n"; app.Alert( s, "OnData" ); } }