This shows you the differences between two versions of the page.
built_in:app_events [2014/10/08 14:38] stevegarman |
built_in:app_events [2018/12/30 13:31] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== App Events ====== | ||
- | There are a few functions that are triggered when certain system events occur. | ||
- | They are | ||
- | |||
- | //Called when application is created | ||
- | 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() | ||
- | |||
- | The code of the sample that is bundled with AndroidScript is reproduced below without permission. Hope you don't mind, guys. | ||
- | <code javascript appEvents.js> | ||
- | //Called when application is created. | ||
- | function OnStart() | ||
- | { | ||
- | app.ShowPopup( " | ||
- | app.SetMenu( " | ||
- | app.EnableBackKey( false ); | ||
- | } | ||
- | |||
- | //Called when user selects a menu item. | ||
- | function OnMenu( name ) | ||
- | { | ||
- | app.ShowPopup( " | ||
- | } | ||
- | |||
- | //Called when the back key is pressed. | ||
- | function OnBack() | ||
- | { | ||
- | alert( " | ||
- | app.Exit(); | ||
- | } | ||
- | |||
- | //Called when application is paused. | ||
- | //(eg. When user switches to home screen) | ||
- | function OnPause() | ||
- | { | ||
- | app.ShowPopup( " | ||
- | } | ||
- | |||
- | //Called when application is resumed. | ||
- | //(eg. When user returns from home screen) | ||
- | function OnResume() | ||
- | { | ||
- | app.ShowPopup( " | ||
- | } | ||
- | |||
- | //Called when configuration changes. | ||
- | //(eg. When user rotates phone) | ||
- | function OnConfig() | ||
- | { | ||
- | app.ShowPopup( " | ||
- | } | ||
- | </ |