Application Life Cycle Methods

In the world of e-commerce, marketers often seek to report on the performance of their advertising tools such as websites or mobile apps so they can adjust their efforts to improve the results. To get analysis of user behavior from your application, you may want to find out which views are more often viewed over others or how users ended up viewing a particular UI. In android, views, e.g., UI's are generally created by xml layouts and they are driven by either an activity or a fragment. Therefore, we may say that life cycle events of activities and fragments are direct representation of user navigation, which holds the key to building marketing strategy.

To track UI views on your Android app, the easiest way would be simply following the life cycle events of activities and fragments. In order to get your data collector setup within any one of these life cycle events, you should set your collection mode on either automatic or manual. Note that activity life cycle events can be tracked under either automatic or manual mode, however fragment life cycle events must be tracked only manually.

Once your application is published out to the Google Play and finally downloaded by app users, it is critically important to find out how your application really behaves in their hands. Whether the app runs without crashing on their handset or how frequently your is app being viewed once it's been installed is vitally important information to be fed into the next development cycle of your application. To find out how your application get starts, comes in and out of foreground or get terminated on a device, there are number of methods available to monitor. These methods can be implemented either automatically or manually depending upon the state of application you would like to monitor.

Initialize application tracking

This enables you to track application opens and exits and uncaught exceptions. Session starts and ends are managed, and the Oracle Infinity queue is initialized to capture both online and offline events. If your application extends the Application base class, you can set it to use the ORABaseApplication class instead. This allows you to streamline application-level measurement by implementing a number of Oracle data collection methods without additional coding.

publicclass HelloWorld extends ORABaseApplication {
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate();
...
}
...
}

Note: If you would rather not extend your application for automatic tracking, then you must call the ORABaseDataCollector.setApplication() method to initialize the SDK before calling any of the event methods. Inside the main application, as the first line in the onCreate method, add the call to setApplication() as follows:

publicclass HelloWorld extends Application {
@Override
publicvoid onCreate(Bundle savedInstanceState) {
// programmatically configure the Library
ORABaseDataCollector.setApplication(this);
...
}
...
}

Toggling Automatic Events

Above is the basic set up to initialize the application tracking. Application life cycle automatic events are disabled by default. You can enable certain events automatic tracking by setting the corresponding config to "true".

  • ora_dc_app_start_auto_enabled: To monitor app start and terminate events
  • ora_dc_error_auto_enabled: To monitor application error/crash events
  • ora_dc_activity_auto_enabled: To monitor activity life cycle events
  • ora_dc_fragment_auto_enabled: To monitor fragment life cycle events
  • ora_dc_push_auto_enabled: To monitor push notification events
  • ora_dc_foreground_auto_enabled: To monitor app foreground and background events

The oracle.json file with above all configurations will be looks like below

{
"config_version": "1.0",
"ORACORE": {
"ora_dc_app_start_auto_enabled": "true",
"ora_dc_error_auto_enabled": "true",
"ora_dc_activity_auto_enabled": "true",
"ora_dc_fragment_auto_enabled": "true",
"ora_dc_push_auto_enabled": "true",
"ora_dc_foreground_auto_enabled": "true"
}
}

The above configurations can also be set using programmatically at run time with ORACoreDataContainer api.

ORACoreDataContainer container = new ORACoreDataContainer(this);
//To monitor app start and terminate events
container.putValue(ORABaseConfigSettings.APP_START_AUTO_ENABLED, "true");
//To monitor application error/crash events
container.putValue(ORABaseConfigSettings.ERROR_AUTO_ENABLED, "true");
//To monitor activity life cycle events
container.putValue(ORABaseConfigSettings.ACTIVITY_AUTO_ENABLED, "true");
//To monitor fragment life cycle events
container.putValue(ORABaseConfigSettings.FRAGMENT_AUTO_ENABLED, "true");
//To monitor push notification events
container.putValue(ORABaseConfigSettings.PUSH_AUTO_ENABLED, "true");
//To monitor app foreground and background events
container.putValue(ORABaseConfigSettings.FOREGROUND_AUTO_ENABLED, "true");

Note: Refer ORABaseConfigKeys for all configuration keys to set through oracle.json

Automatic Event Definitions

Application Lifecycle events

Application Start

Collects data when Application.onCreate is executed. This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue.

Syntax
Map<String, String> triggerApplicationStartEvent(final String applicationName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerApplicationStartEvent("Hello World Application Start", customData);
Parameters
  • applicationName: Specifies an application name associated with application startup, application termination, application foreground, application background, or application error.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /application/start
  • WT.ti: applicationName
  • WT.pi: applicationName
  • WT.sys: startup
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Application Enter Background

Collects data when Application.onStopped is executed. This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue.

Syntax
Map<String, String> triggerApplicationEnterBackgroundEvent(final String applicationName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerApplicationEnterBackgroundEvent("Hello World Application Entered Background", customData);
Parameters
  • applicationName: Specifies an application name associated with application startup, application termination, application foreground, application background, or application error.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /application/background
  • WT.ti: applicationName
  • WT.pi: applicationName
  • WT.sys: background
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Application Enter Foreground

Collects data when Application.onResumed is executed. This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue.

Syntax
Map<String, String> triggerApplicationEnterForegroundEvent(final String applicationName, final Map<String, String> customData)
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerApplicationEnterForegroundEvent(activityName, customData);
Parameters
  • applicationName: Specifies an application name associated with application startup, application termination, application foreground, application background, or application error.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /application/foreground
  • WT.ti: applicationName
  • WT.pi: applicationName
  • WT.sys: foreground
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Application Error

Collects data when ORABaseApplication is passed an uncaught exception.

This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue

Syntax
Map<String, String> triggerApplicationErrorEvent(final String applicationName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerApplicationErrorEvent("Hello World Application Error", customData);
Parameters
  • applicationName: Specifies an application name associated with application startup, application termination, application foreground, application background, or application error.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /application/error
  • WT.ti: applicationName
  • WT.pi: applicationName
  • WT.sys: error
  • WT.dl: 64

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Application Terminate

Collects data when Application.onTerminate is executed. This method only can be called manually accepting custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue.

Note: This event can not be generated/tracked automatically. This is because of the way the application onTerminate callback method is handled by Android. See Android Application page for details.

Syntax
Map<String, String> triggerApplicationTerminateEvent(final String applicationName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerApplicationTerminateEvent(""Hello World Application Terminate"", customData);
Parameters
  • applicationName: Specifies an application name associated with application startup, application termination, application foreground, application background, or application error.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /application/terminate
  • WT.ti: applicationName
  • WT.pi: applicationName
  • WT.sys: exit
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Activity Lifecycle Events

Activity Start

Collects data when an activity starts if the application is extended with “ORABaseApplication” and Activity.onCreate or Activity.onStart is executed.

This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue

Syntax
Map<String, String> triggerActivityStartEvent(final String activityName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerActivityStartEvent("Hello World Activity Start", customData);
Parameters
  • activityName: Specifies an activity name associated with the end of user activity.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /activity/start
  • WT.ti: activityName
  • WT.pi: activityName
  • WT.sys: start
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Activity Resume

Collects data when an activity resumed if the application is extended with “ORABaseApplication” and onActivityResumed is executed.

This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue

Syntax
Map<String, String> triggerActivityResumeEvent(final String activityName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerActivityResumeEvent("Hello World Activity Resume", customData);
Parameters
  • activityName: Specifies an activity name associated with the end of user activity.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /activity/resume
  • WT.ti: activityName
  • WT.pi: activityName
  • WT.sys: resume
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Activity Pause

Collects data when an activity is paused if the application is extended with “ORABaseApplication” and Activity.onPause is executed. This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue

Syntax
Map<String, String> triggerActivityPauseEvent(final String activityName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerActivityPauseEvent("Hello World Activity Pause", customData);
Parameters
  • activityName: Specifies an activity name associated with the end of user activity.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /activity/pause
  • WT.ti: activityName
  • WT.pi: activityName
  • WT.sys: pause
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.

Activity Stop

Collects data when an activity stops if the application is extended with “ORABaseApplication” and Activity.onStop is executed. This method can also be called manually, in which case it can accept custom parameters using a Map of key/value pairs. These custom parameters are appended to Oracle Infinity data using the following format: &customKey=customValue

Syntax
Map<String, String> triggerActivityStopEvent(final String activityName, final Map<String, String> customData);
Example
// Send custom key/value pairs as arguments to event methods (optional)
Map <String, String> customData = new HashMap<String, String>();
customData.put("custom_key", "custom_value");
ORABaseDataCollector.getInstance().triggerActivityStopEvent("Hello World Activity End", customData);
Parameters
  • activityName: Specifies an activity name associated with the end of user activity.
  • customData (optional): Specifies a series of custom name-value parameters used to pass data that is not included in the method.
Oracle Infinity Parameter Values
  • dcsuri: /activity/end
  • WT.ti: activityName
  • WT.pi: activityName
  • WT.sys: end
  • WT.dl: 61

Additional params sent in every event are detailed in the Oracle Infinity Parameters Sent by the SDK section.