This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
built_in:app_events [2014/10/08 15:58] cokeramirez add OnAlarm() |
built_in:app_events [2017/09/17 22:32] 5.48.46.31 [Table] |
||
---|---|---|---|
Line 3: | Line 3: | ||
They are | They are | ||
+ | ^ Function | ||
+ | | OnStart() | ||
+ | | OnMenu( name ) | user selects a menu item | | ||
+ | | OnBack() | ||
+ | | OnPause() | ||
+ | | OnResume() | ||
+ | | OnConfig() | ||
+ | | OnAlarm() | ||
+ | | OnData() | ||
- | //Called when application is created | + | The code of the sample that is bundled with DroidScript |
- | function OnStart() | + | |
- | . | + | |
- | //Called when user selects a menu item. | + | |
- | function OnMenu( name ) | + | |
- | . | + | |
- | //Called when the back key is pressed. | + | |
- | // but only if it follows app.EnableBackKey( false ); | + | |
- | function OnBack() | + | |
- | . | + | |
- | //Called when application is paused. (eg. When user switches to home screen) | + | |
- | function OnPause() | + | |
- | . | + | |
- | //Called when application is resumed. (eg. When user returns from home screen) | + | |
- | function OnResume() | + | |
- | . | + | |
- | //Called when configuration changes. (eg. When user rotates phone) | + | |
- | function OnConfig() | + | |
- | . | + | |
- | //Called when an alarm previously set by app.SetAlarm() is triggered. | + | |
- | function OnAlarm() | + | |
- | + | ||
- | The code of the sample that is bundled with AndroidScript | + | |
<code javascript appEvents.js> | <code javascript appEvents.js> | ||
//Called when application is created. | //Called when application is created. | ||
Line 34: | Line 21: | ||
app.SetMenu( " | app.SetMenu( " | ||
app.EnableBackKey( false ); | app.EnableBackKey( false ); | ||
- | } | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
//Called when user selects a menu item. | //Called when user selects a menu item. | ||
Line 69: | Line 60: | ||
app.ShowPopup( " | app.ShowPopup( " | ||
} | } | ||
+ | |||
+ | // | ||
+ | // | ||
+ | function OnAlarm( id ) | ||
+ | { | ||
+ | app.ShowPopup( " | ||
+ | } | ||
+ | |||
+ | //Handle data sent from other apps. | ||
+ | function OnData( isStartUp ) | ||
+ | { | ||
+ | | ||
+ | var intent = app.GetIntent(); | ||
+ | if( intent ) | ||
+ | { | ||
+ | //Extract main data. | ||
+ | var s = " | ||
+ | s += "type: " + intent.type + " | ||
+ | s += "data: " + intent.data + " | ||
+ | | ||
+ | //Extract extras. | ||
+ | s += " | ||
+ | for( var key in intent.extras ) | ||
+ | s += key+": " | ||
+ | | ||
+ | app.Alert( s, " | ||
+ | } | ||
+ | } | ||
+ | |||
</ | </ |