public class Countly
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Countly.CountlyMessagingMode
Enum used in Countly.initMessaging() method which controls what kind of
app installation it is.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COUNTLY_SDK_VERSION_STRING
Current version of the Count.ly Android SDK as a displayable string.
|
static java.lang.String |
DEFAULT_APP_VERSION
Default string used in the begin session metrics if the
app version cannot be found.
|
static java.lang.String |
TAG
Tag used in all logging in the Count.ly SDK.
|
Modifier and Type | Method and Description |
---|---|
void |
halt()
Immediately disables session & event tracking and clears any stored session & event data.
|
Countly |
init(Context context,
java.lang.String serverURL,
java.lang.String appKey)
Initializes the Countly SDK.
|
Countly |
init(Context context,
java.lang.String serverURL,
java.lang.String appKey,
java.lang.String deviceID)
Initializes the Countly SDK.
|
Countly |
init(Context context,
java.lang.String serverURL,
java.lang.String appKey,
java.lang.String deviceID,
DeviceId.Type idMode)
Initializes the Countly SDK.
|
Countly |
initMessaging(Activity activity,
java.lang.Class<? extends Activity> activityClass,
java.lang.String projectID,
Countly.CountlyMessagingMode mode)
Initializes the Countly MessagingSDK.
|
Countly |
initMessaging(Activity activity,
java.lang.Class<? extends Activity> activityClass,
java.lang.String projectID,
java.lang.String[] buttonNames,
Countly.CountlyMessagingMode mode)
Initializes the Countly MessagingSDK.
|
boolean |
isInitialized()
Checks whether Countly.init has been already called.
|
boolean |
isLoggingEnabled() |
void |
onRegistrationId(java.lang.String registrationId)
Called when GCM Registration ID is received.
|
void |
onStart()
Tells the Countly SDK that an Activity has started.
|
void |
onStop()
Tells the Countly SDK that an Activity has stopped.
|
void |
recordEvent(java.lang.String key)
Records a custom event with no segmentation values, a count of one and a sum of zero.
|
void |
recordEvent(java.lang.String key,
int count)
Records a custom event with no segmentation values, the specified count, and a sum of zero.
|
void |
recordEvent(java.lang.String key,
int count,
double sum)
Records a custom event with no segmentation values, and the specified count and sum.
|
void |
recordEvent(java.lang.String key,
java.util.Map<java.lang.String,java.lang.String> segmentation,
int count)
Records a custom event with the specified segmentation values and count, and a sum of zero.
|
void |
recordEvent(java.lang.String key,
java.util.Map<java.lang.String,java.lang.String> segmentation,
int count,
double sum)
Records a custom event with the specified values.
|
Countly |
setDisableUpdateSessionRequests(boolean disable)
Disable periodic session time updates.
|
Countly |
setLoggingEnabled(boolean enableLogging)
Sets whether debug logging is turned on or off.
|
void |
setUserData(Bundle data)
Sets information about user.
|
static Countly |
sharedInstance()
Returns the Countly singleton.
|
public static final java.lang.String COUNTLY_SDK_VERSION_STRING
public static final java.lang.String DEFAULT_APP_VERSION
public static final java.lang.String TAG
public static Countly sharedInstance()
public Countly init(Context context, java.lang.String serverURL, java.lang.String appKey)
context
- application contextserverURL
- URL of the Countly server to submit data to; use "https://cloud.count.ly" for Countly CloudappKey
- app key for the application being tracked; find in the Countly Dashboard under Management > Applicationsjava.lang.IllegalArgumentException
- if context, serverURL, appKey, or deviceID are invalidjava.lang.IllegalStateException
- if the Countly SDK has already been initializedpublic Countly init(Context context, java.lang.String serverURL, java.lang.String appKey, java.lang.String deviceID)
context
- application contextserverURL
- URL of the Countly server to submit data to; use "https://cloud.count.ly" for Countly CloudappKey
- app key for the application being tracked; find in the Countly Dashboard under Management > ApplicationsdeviceID
- unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to OpenUDID, then, if it's not available, to Google Advertising IDjava.lang.IllegalArgumentException
- if context, serverURL, appKey, or deviceID are invalidjava.lang.IllegalStateException
- if init has previously been called with different values during the same application instancepublic Countly init(Context context, java.lang.String serverURL, java.lang.String appKey, java.lang.String deviceID, DeviceId.Type idMode)
context
- application contextserverURL
- URL of the Countly server to submit data to; use "https://cloud.count.ly" for Countly CloudappKey
- app key for the application being tracked; find in the Countly Dashboard under Management > ApplicationsdeviceID
- unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to OpenUDID, then, if it's not available, to Google Advertising IDidMode
- enum value specifying which device ID generation strategy Countly should use: OpenUDID or Google Advertising IDjava.lang.IllegalArgumentException
- if context, serverURL, appKey, or deviceID are invalidjava.lang.IllegalStateException
- if init has previously been called with different values during the same application instancepublic boolean isInitialized()
public Countly initMessaging(Activity activity, java.lang.Class<? extends Activity> activityClass, java.lang.String projectID, Countly.CountlyMessagingMode mode)
activity
- application activity which acts as a final destination for notificationsactivityClass
- application activity class which acts as a final destination for notificationsprojectID
- ProjectID for this app from Google API Consolemode
- whether this app installation is a test release or productionjava.lang.IllegalStateException
- if no CountlyMessaging class is found (you need to use countly-messaging-sdk-android library instead of countly-sdk-android)public Countly initMessaging(Activity activity, java.lang.Class<? extends Activity> activityClass, java.lang.String projectID, java.lang.String[] buttonNames, Countly.CountlyMessagingMode mode)
activity
- application activity which acts as a final destination for notificationsactivityClass
- application activity class which acts as a final destination for notificationsprojectID
- ProjectID for this app from Google API ConsolebuttonNames
- Strings to use when displaying Dialogs (uses new String[]{"Open", "Review"} by default)mode
- whether this app installation is a test release or productionjava.lang.IllegalStateException
- if no CountlyMessaging class is found (you need to use countly-messaging-sdk-android library instead of countly-sdk-android)public void halt()
public void onStart()
java.lang.IllegalStateException
- if Countly SDK has not been initializedpublic void onStop()
java.lang.IllegalStateException
- if Countly SDK has not been initialized, or if
unbalanced calls to onStart/onStop are detectedpublic void onRegistrationId(java.lang.String registrationId)
public void recordEvent(java.lang.String key)
key
- name of the custom event, required, must not be the empty stringjava.lang.IllegalStateException
- if Countly SDK has not been initializedjava.lang.IllegalArgumentException
- if key is null or emptypublic void recordEvent(java.lang.String key, int count)
key
- name of the custom event, required, must not be the empty stringcount
- count to associate with the event, should be more than zerojava.lang.IllegalStateException
- if Countly SDK has not been initializedjava.lang.IllegalArgumentException
- if key is null or emptypublic void recordEvent(java.lang.String key, int count, double sum)
key
- name of the custom event, required, must not be the empty stringcount
- count to associate with the event, should be more than zerosum
- sum to associate with the eventjava.lang.IllegalStateException
- if Countly SDK has not been initializedjava.lang.IllegalArgumentException
- if key is null or emptypublic void recordEvent(java.lang.String key, java.util.Map<java.lang.String,java.lang.String> segmentation, int count)
key
- name of the custom event, required, must not be the empty stringsegmentation
- segmentation dictionary to associate with the event, can be nullcount
- count to associate with the event, should be more than zerojava.lang.IllegalStateException
- if Countly SDK has not been initializedjava.lang.IllegalArgumentException
- if key is null or emptypublic void recordEvent(java.lang.String key, java.util.Map<java.lang.String,java.lang.String> segmentation, int count, double sum)
key
- name of the custom event, required, must not be the empty stringsegmentation
- segmentation dictionary to associate with the event, can be nullcount
- count to associate with the event, should be more than zerosum
- sum to associate with the eventjava.lang.IllegalStateException
- if Countly SDK has not been initializedjava.lang.IllegalArgumentException
- if key is null or empty, count is less than 1, or if
segmentation contains null or empty keys or valuespublic void setUserData(Bundle data)
data
- Bundle with user datapublic Countly setDisableUpdateSessionRequests(boolean disable)
disable
- whether or not to disable session time updatespublic Countly setLoggingEnabled(boolean enableLogging)
enableLogging
- true to enable logging, false to disable loggingpublic boolean isLoggingEnabled()