public final class FlurryAgent extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addOrigin(String originName,
String originVersion)
Add origin attribution.
|
static void |
addOrigin(String originName,
String originVersion,
Map<String,String> originParameters)
Add origin attribution with parameters.
|
static void |
addSessionProperty(String name,
String value) |
static void |
clearLocation()
Clear the default location.
|
static void |
endTimedEvent(String eventId)
End a timed event.
|
static void |
endTimedEvent(String eventId,
Map<String,String> parameters)
End a timed event.Only up to 10 unique parameters total can be passed for an event, including those
passed when the event was initiated.
|
static int |
getAgentVersion()
Get the version of the Flurry SDK.
|
static String |
getReleaseVersion()
Get the release version of the Flurry SDK.
|
static String |
getSessionId()
Check to see if there is an active session.
|
static void |
init(Context context,
String apiKey)
Initialize the Flurry SDK.
|
static boolean |
isSessionActive()
Check to see if there is an active session.
|
static FlurryEventRecordStatus |
logEvent(FlurrySyndicationEventName eventName,
String syndicationId,
Map<String,String> parameters)
Log a syndicated event with parameters.
|
static FlurryEventRecordStatus |
logEvent(String eventId)
Log an event.
|
static FlurryEventRecordStatus |
logEvent(String eventId,
boolean timed)
Log a timed event.
|
static FlurryEventRecordStatus |
logEvent(String eventId,
Map<String,String> parameters)
Log an event with parameters.
|
static FlurryEventRecordStatus |
logEvent(String eventId,
Map<String,String> parameters,
boolean timed)
Log a timed event with parameters.
|
static void |
onEndSession(Context context)
End a Flurry session for the given Context.
|
static void |
onError(String errorId,
String message,
String errorClass)
Deprecated.
|
static void |
onError(String errorId,
String message,
Throwable exception) |
static void |
onEvent(String eventId)
Deprecated.
See
logEvent(String) . |
static void |
onEvent(String eventId,
Map<String,String> parameters)
Deprecated.
|
static void |
onPageView()
Log a page view.
|
static void |
onStartSession(Context context)
Start or continue a Flurry session for the project on the given Context.
|
static void |
onStartSession(Context context,
String apiKey)
Deprecated.
|
static void |
setAge(int age)
Sets the age of the user at the time of this session.
|
static void |
setCaptureUncaughtExceptions(boolean isEnabled)
True to enable or false to disable the ability to catch all uncaught exceptions
and have them reported back to Flurry.
|
static void |
setContinueSessionMillis(long millis)
Set the timeout for expiring a Flurry session.
|
static void |
setFlurryAgentListener(FlurryAgentListener listener)
Sets the listener.
|
static void |
setGender(byte gender)
Sets the gender of the user.
|
static void |
setLocation(float lat,
float lon)
Set the default location.
|
static void |
setLocationCriteria(Criteria locationCriteria)
Deprecated.
Flurry SDK now uses PASSIVE_PROVIDER to fetch the location information if app
has ACCESS_FINE_LOCATION permission.
|
static void |
setLogEnabled(boolean isEnabled)
True to enable or false to disable the internal logging for the Flurry SDK.
|
static void |
setLogEvents(boolean logEvents)
True to enable event logging or false to disable event logging.
|
static void |
setLogLevel(int logLevel)
Set the log level of the internal Flurry SDK logging.
|
static void |
setPulseEnabled(boolean isEnabled)
True to enable or false to disable Flurry Pulse.
|
static void |
setReportLocation(boolean reportLocation)
Set whether Flurry should record location via GPS.
|
static void |
setSessionOrigin(String originName,
String deepLink) |
static void |
setUserId(String userId)
Sets the Flurry userId for this session.
|
static void |
setVersionName(String versionName)
Set the version name of the app.
|
public static int getAgentVersion()
public static String getReleaseVersion()
public static void setFlurryAgentListener(FlurryAgentListener listener)
listener
- Your implementation of the Flurry agent listener.public static void setLogEnabled(boolean isEnabled)
isEnabled
- true to enable logging, false to disable it.public static void setLogLevel(int logLevel)
logLevel
- The level to set it to.public static void setVersionName(String versionName)
versionName
- The version of the app.public static void setReportLocation(boolean reportLocation)
reportLocation
- True to allow Flurry to record location via GPS, false otherwisepublic static void setLocation(float lat, float lon)
lat
- The latitudelon
- The longitudepublic static void clearLocation()
public static void setContinueSessionMillis(long millis)
millis
- The time in milliseconds to set the session timeout to. Minimum value of 5000.onStartSession(Context, String)
,
onEndSession(Context)
public static void setLogEvents(boolean logEvents)
logEvents
- true to log events, false to disable event logging.public static void setCaptureUncaughtExceptions(boolean isEnabled)
isEnabled
- true to enable, false to disable.public static void addOrigin(String originName, String originVersion)
FlurryAgent.addOrigin("An Origin without Params", "Origin Version");
originName
- The name/id of the origin you wish to attribute.originVersion
- The version of the origin you wish to attribute.addOrigin(String, String, Map)
public static void addOrigin(String originName, String originVersion, Map<String,String> originParameters)
// Add an origin with params, where param1=value1 and param2=value2 Map<String, String>
params = new HashMap<String, String>(); params.put("param1", "value1");
params.put("param2", "value2"); FlurryAgent.addOrigin("An Origin with Params", "Origin Version",
params);
originName
- The name/id of the origin you wish to attribute.originVersion
- The version of the origin you wish to attribute.originParameters
- A Map<String, String>
of the parameters which should be submitted with this
origin attribution.addOrigin(String, String)
public static void setPulseEnabled(boolean isEnabled)
isEnabled
- true to enable, false to disable.public static void init(Context context, String apiKey)
context
- A reference to a android.content.Context object such as an android.app.Activity or an android.app.Service.apiKey
- The API key for your application.@Deprecated public static void onStartSession(Context context, String apiKey)
onStartSession(Context)
context
- apiKey
- public static void onStartSession(Context context)
// The Activity's onStart method
protected void onStart() { // Start the Flurry session
FlurryAgent.onStartSession(this); }
So long as there is any Context that has called #onStartSession(Context)
but not onEndSession(Context)
, the session will be continued. Also, if a new Context
calls #onStartSession(Context) within 10 seconds (the default session timeout
length) of the last Context calling onEndSession, then the session will be resumed,
instead of a new session being created. Session length, usage frequency, events and
errors will continue to be tracked as part of the same session. This ensures that as a
user transitions from one Activity to another in your application they will not have a
separate session tracked for each Activity, but will have a single session that spans
many activities. #onStartSession should be called from within the onStart method of
the activity in question. The first call to onStartSession will set up the
configuration for all later occurring calls to onStartSession.
Please note that if your app only runs on ICS+ (minSdkVersion >= 14)
Activity-based
sessions will be handled for you automatically. There is no need to call this method
unless you wish to track another type of Context.context
- A reference to a android.content.Context object such as an android.app.Activity or an android.app.Service.setContinueSessionMillis(long)
public static void onEndSession(Context context)
// The Activity's onStop method
protected void onStop() {
FlurryAgent.onEndSession(this);
}
Pop a session off the stack for this Activity. If no sessions remain after the
call to onEndSession(Context) and no new calls to onStartSession(Context, String)
are made within the timeout specified (which defaults to 10 seconds) then the session
will truly end. Calls to #onEndSession should be made from the Activity's onStop
method in order to assure a complete analytics lifecycle for the Activity.
Please note that if your app only runs on ICS+ (minSdkVersion >= 14)
Activity-based
sessions will be handled for you automatically. There is no need to call this method
unless you wish to track another type of Context.context
- A reference to a android.content.Context object such as an android.app.Activity or an android.app.Service.setContinueSessionMillis(long)
public static boolean isSessionActive()
onStartSession(Context, String)
in the Android onStart method with a call to onEndSession(Context)
in the Android onEnd
method. At any point, you can call this method to find if there is an active running session.public static String getSessionId()
onStartSession(Context, String)
in the Android onStart
method with a call to onEndSession(Context)
in the Android onEnd method. At any point,
you can call this method to get the active session id.public static FlurryEventRecordStatus logEvent(String eventId)
FlurryAgent.logEvent("An Event without Params");
eventId
- The name/id of the event.logEvent(String, Map)
,
logEvent(String, Map, boolean)
public static FlurryEventRecordStatus logEvent(String eventId, Map<String,String> parameters)
// Log an event with params, where param1=value1 and param2=value2 Map<String, String>
params = new HashMap<String, String>(); params.put("param1", "value1");
params.put("param2", "value2"); FlurryAgent.logEvent("Event with params", params);
Log an event with parameters with the Flurry service. The event is identified by the
eventId, which is a String. A Map<String, String>
of parameters can be passed in where
the key is the parameter name, and the value is the value.eventId
- The name/id of the event.parameters
- A Map<String, String>
of the parameters which should be submitted with this
event.logEvent(String)
,
logEvent(String, Map, boolean)
public static FlurryEventRecordStatus logEvent(FlurrySyndicationEventName eventName, String syndicationId, Map<String,String> parameters)
eventName
- The name of the event. Choose one from the enum.syndicationId
- The syndicationId of the event.parameters
- A Map<String, String>
of the parameters which should be submitted with this
event.public static FlurryEventRecordStatus logEvent(String eventId, boolean timed)
eventId
- The name/id of the event.timed
- True if the event should be timed, false otherwise.endTimedEvent(String)
,
logEvent(String)
public static FlurryEventRecordStatus logEvent(String eventId, Map<String,String> parameters, boolean timed)
eventId
- The name/id of the event.parameters
- A Map<String, String>
of parameters to log with this event.timed
- True if this event is timed, false otherwise.logEvent(String, Map)
public static void endTimedEvent(String eventId)
eventId
- The name/id of the event to end the timer on.for more details.
public static void endTimedEvent(String eventId, Map<String,String> parameters)
eventId
- The name/id of the event to end the timer on.parameters
- A Map<String, String>
of parameters to log with this event.logEvent(String, Map)
@Deprecated public static void onError(String errorId, String message, String errorClass)
onError(String, String, Throwable)
errorId
- message
- errorClass
- @Deprecated public static void onEvent(String eventId)
logEvent(String)
.eventId
- @Deprecated public static void onEvent(String eventId, Map<String,String> parameters)
logEvent(String, Map)
eventId
- parameters
- public static void onPageView()
@Deprecated public static void setLocationCriteria(Criteria locationCriteria)
setReportLocation(boolean)
public static void setAge(int age)
age
- valid values are 0-110public static void setGender(byte gender)
gender
- One of the values among Constants#MALE, Constants#FEMALE and Constants#UNKNOWN
as defined in Constants.public static void setUserId(String userId)
userId
-