public class GoogleAnalytics
extends java.lang.Object
Tracker
can exist
for any particular trackingId
.
You can get an instance of this class by calling getInstance(Context)
.
This class also manages the debug flag.
Modifier and Type | Class and Description |
---|---|
static interface |
GoogleAnalytics.AppOptOutCallback
Interface for retrieving the current state of the Application-level opt out flag.
|
Modifier and Type | Method and Description |
---|---|
void |
closeTracker(Tracker tracker)
Closes the tracker.
|
Tracker |
getDefaultTracker()
Returns the default
Tracker if one exists. |
static GoogleAnalytics |
getInstance(Context context)
Get the instance of the
GoogleAnalytics class, creating it if necessary. |
Tracker |
getTracker(java.lang.String trackingId)
Multiple instances of a
Tracker can be created as long as each has its own
trackingId . |
boolean |
isDebugEnabled()
Returns whether debug mode is on.
|
void |
requestAppOptOut(GoogleAnalytics.AppOptOutCallback callback)
Requests whether the state of the application-level opt is on.
|
void |
sendHit(java.util.Map<java.lang.String,java.lang.String> hit)
Create and queue a hit based on the data in hitData.
|
void |
setAppOptOut(boolean optOut)
Sets or resets the application-level opt out flag.
|
void |
setDebug(boolean debug)
Toggles debug mode.
|
void |
setDefaultTracker(Tracker tracker)
Sets the default
Tracker . |
public static GoogleAnalytics getInstance(Context context)
GoogleAnalytics
class, creating it if necessary.public void setDebug(boolean debug)
By default, this flag is disabled.
public boolean isDebugEnabled()
public Tracker getTracker(java.lang.String trackingId)
Tracker
can be created as long as each has its own
trackingId
. If a Tracker
has already been created (and not yet closed) for a
given trackingId
, that Tracker
will be returned.trackingId
- string of the form UA-xxxx-ypublic Tracker getDefaultTracker()
public void closeTracker(Tracker tracker)
tracker
- the tracker that is no longer neededpublic void sendHit(java.util.Map<java.lang.String,java.lang.String> hit)
hit
- the data for the hitpublic void setAppOptOut(boolean optOut)
optOut
- true if application-level opt out should be enforcedpublic void requestAppOptOut(GoogleAnalytics.AppOptOutCallback callback)
GoogleAnalytics.AppOptOutCallback.reportAppOptOut(boolean)
method will be called with the answer once it's been
calculated. The callback GoogleAnalytics.AppOptOutCallback.reportAppOptOut(boolean)
may be called either before
or after this method returns.
It may be called from a different thread.
callback
- to use to report application-level opt out flag