- Print
- DarkLight
- PDF
Application State Collection Methods
Once your application is published out to 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 device or how frequently your app is 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 gets started, comes in and out of foreground, or gets terminated on a device, there are a number of methods available for monitoring. These methods can be implemented either automatically or manually depending upon the state of application you would like to monitor.
For example, if you'd like to automatically monitor when your app gets started, comes into the foreground or background, you must enable the following configuration by setting the value to true
in your MyApp/res/values/webtrends.xml.
<string name="wt_dc_activity_automatics_enabled">true</string>
However, if you want to extend beyond scope of simply monitoring activity life cycles alone, you can also manually trigger events such as initial launch, normal exit or app terminated by error and etc.
onActivityStart
The onActivityStart
method automatically collects data when an activity starts if the application is extended with “WTApplication” 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 Webtrends data using the following format:
&customKey=customValue
Syntax
public void onActivityStart(String activityName, 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");
WebtrendsDataCollector.getInstance().onActivityStart("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.
Throws
IllegalArgumentException
: Returned when an argument is malformed.
Webtrends Parameter Values
dcsuri
: /activity/startWT.ti
: activityNameWT.pi
: activityNameWT.sys
: startWT.dl
: 61
Additional parameters sent in every event are detailed in the Webtrends Parameters Sent by the Mobile SDK section.
onActivityPause
The onActivityPause
method automatically collects data when an activity is paused if the application is extended with “WTApplication” 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 Webtrends data using the following format:
&customKey=customValue
Syntax
public void onActivityPause(String activityName,
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");
WebtrendsDataCollector.getInstance().onActivityPause("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.
Webtrends Parameter Values
dcsuri
: /activity/pauseWT.ti
: activityNameWT.pi
: activityNameWT.sys
: pauseWT.dl
: 61
Additional parameters sent in every event are detailed in the Webtrends Parameters Sent by the Mobile SDK section.
onActivityEnd
The onActivityEnd
method automatically collects data when an activity stops if the application is extended with “WTApplication” 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 Webtrends data using the following format:
&customKey=customValue
Syntax
public void onActivityEnd(String activityName,
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");
WebtrendsDataCollector.getInstance().onActivityEnd("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.
Throws
IllegalArgumentException
: Returned when an argument is malformed.
Webtrends Parameter Values
dcsuri
: /activity/endWT.ti
: activityNameWT.pi
: activityNameWT.sys
: endWT.dl
: 61
Additional parameters sent in every event are detailed in the Webtrends Parameters Sent by the Mobile SDK section.
onApplicationError
The onApplicationError
method collects data when WTapplication
is passed in 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 Webtrends data using the following format:
&customKey=customValue
Syntax
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");
WebtrendsDataCollector.getInstance().onApplicationError("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.
Throws
IllegalArgumentException
: Returned when an argument is malformed.
Webtrends Parameter Values
dcsuri
: /application/errorWT.ti
: applicationNameWT.pi
: applicationNameWT.sys
: errorWT.dl
: 61
Additional parameters sent in every event are detailed in the Webtrends Parameters Sent by the Mobile SDK section.
onApplicationStart
The onApplicationStart
method 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 Webtrends data using the following format:
a &customKey=customValue
Syntax
public void onApplicationStart(String applicationName,
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");
try {
WebtrendsDataCollector.getInstance().onApplicationStart("Hello World Application Start", customData);
} catch (IllegalWebtrendsParameterValueException e) {
// log error message
WebtrendsDataCollector.getInstance().getLog().e(e.getMessage());
}
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.
Throws
IllegalArgumentException
: Returned when an argument is malformed.
Webtrends Parameter Values
dcsuri
: /application/startWT.ti
: applicationNameWT.pi
: applicationNameWT.sys
: startupWT.dl
: 61
Additional parameters sent in every event are detailed in the Webtrends Parameters Sent by the Mobile SDK section.
onApplicationTerminate
The onApplicationTerminate
method collects data when Application.onTerminate
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 Webtrends data using the following format:
a &customKey=customValue
This method returns a WTEvent
that indicates the application has terminated. No arguments are required.
Syntax
public void onApplicationTerminate(String applicationName,
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");
WebtrendsDataCollector.getInstance().onApplicationTerminate("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.
Webtrends Parameter Values
dcsuri
: /application/terminateWT.ti
: applicationNameWT.pi
: applicationNameWT.sys
: exitWT.dl
: 61
Additional parameters sent in every event are detailed in the Webtrends Parameters Sent by the Mobile SDK section.