public class

Analytics

extends Object
java.lang.Object
   ↳ com.urbanairship.analytics.Analytics

Class Overview

This class is the primary interface to the UrbanAirship Analytics API.

Summary

Constants
String ACTION_APP_BACKGROUND Intent action for application background.
String ACTION_APP_FOREGROUND Intent action for application foreground.
Public Methods
static void activityStarted(Activity activity)
Call this in your Activity's onStart method to notify Analytics that the activity has started.
static void activityStopped(Activity activity)
Call this in your Activity's onStop method to notify Analytics that the activity has stopped.
void addEvent(Event event)
Adds an analytics event.
void associateIdentifiers(AssociatedIdentifiers identifiers)
Associates identifiers with the device.
String getConversionSendId()
Returns the last stored send Id from when a push conversion was detected.
boolean isAppInForeground()
Determines if the application is in the foreground.
boolean isEnabled()
Returns true if analytics is enabled and analyticsEnabled is set to true, otherwise false.
void recordLocation(Location location)
Records a location.
void recordLocation(Location location, LocationRequestOptions options, LocationEvent.UpdateType updateType)
Records a location.
void setEnabled(boolean enabled)
Sets analytics enabled.
void trackScreen(String screen)
Initiates screen tracking for a specific app screen, must be called once per tracked screen.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_APP_BACKGROUND

Intent action for application background.

Constant Value: "com.urbanairship.analytics.APP_BACKGROUND"

public static final String ACTION_APP_FOREGROUND

Intent action for application foreground.

Constant Value: "com.urbanairship.analytics.APP_FOREGROUND"

Public Methods

public static void activityStarted (Activity activity)

Call this in your Activity's onStart method to notify Analytics that the activity has started. This is non-blocking and should be called on the application's main thread. If your application targets Android Ice Cream Sandwich (api 14) or above, this method is no longer required.

Parameters
activity The activity that is currently starting.

public static void activityStopped (Activity activity)

Call this in your Activity's onStop method to notify Analytics that the activity has stopped. This is non-blocking and should be called on the application's main thread. If your application targets Android Ice Cream Sandwich (api 14) or above, this method is no longer required.

Parameters
activity The activity that is currently stopping.

public void addEvent (Event event)

Adds an analytics event.

Parameters
event The event to be triggered.

public void associateIdentifiers (AssociatedIdentifiers identifiers)

Associates identifiers with the device. This will create and add an event that will be sent up with other analytics events. Previous associated identifiers will be replaced.

Parameters
identifiers An AssociatedIdentifiers instance.

public String getConversionSendId ()

Returns the last stored send Id from when a push conversion was detected.

Returns
  • A send Id String.

public boolean isAppInForeground ()

Determines if the application is in the foreground.

Returns
  • true if the application is in the foreground, otherwise false.

public boolean isEnabled ()

Returns true if analytics is enabled and analyticsEnabled is set to true, otherwise false.

Features that depend on analytics being enabled may not work properly if it's disabled (reports, region triggers, location segmentation, push to local time).

Returns
  • true if analytics is enabled, otherwise false.

public void recordLocation (Location location)

Records a location.

Parameters
location The location to record.

public void recordLocation (Location location, LocationRequestOptions options, LocationEvent.UpdateType updateType)

Records a location.

Parameters
location The new location.
options The location request options.
updateType The update type.

public void setEnabled (boolean enabled)

Sets analytics enabled. When disabling analytics, any locally stored events will be deleted.

Features that depend on analytics being enabled may not work properly if it's disabled (reports, region triggers, location segmentation, push to local time).

Parameters
enabled true to enable analytics, false to disable.

public void trackScreen (String screen)

Initiates screen tracking for a specific app screen, must be called once per tracked screen.

Parameters
screen The screen's string identifier.