Important Note:
This article has been moved to our Developer Center, and will no longer be updated on this site. Here is the newest version of our Android SDK Docs.
This article describes all the available SDK methods for Amplitude's Android SDK. The variables and values in red are what you will need to replace with your own. Please see the Android SDK Installation documentation for instructions on how to install the SDK. For more developer specific content, please feel free to visit our Developer Centre here.
Table of Contents
- Class: Amplitude
- Class: AmplitudeClient
- Class: Identify
- Class: PinnedAmplitudeClient
- Class: PinnedAmplitudeClient.SSLContextBuilder
- Class: Revenue
Class: Amplitude
public class Amplitude extends java.lang.Object
Note: All of the methods except getInstance()
have been deprecated. Please call those methods on the AmplitudeClient instance instead (e.g. Amplitude.getInstance().logEvent();
). More information about this class can be found here.
Constructor
Amplitude()
public Amplitude()
Methods
getInstance
public static AmplitudeClient getInstance()
This method gets the default instance. This is the only method you should be calling on the Amplitude class.
Returns: The default instance.
Class: AmplitudeClient
public class AmplitudeClient extends java.lang.Object
This is the SDK instance class that contains all of the SDK functionality. Note: Call the methods on the default shared instance in the Amplitude class (e.g. Amplitude.getInstance().logEvent();
). Many of the SDK functions return the SDK instance back, allowing you to chain multiple method calls together. For example:
Amplitude.getInstance().initialize(this, "API_KEY").enableForegroundTracking(getApplication())
Fields
1. protected Context context;
The Android App context.
2. protected OkHttpClient httpClient;
The shared OkHTTPClient
instance.
3. protected DatabaseHelper dbhelper;
The shared Amplitude database helper instance.
4. protected String apiKey;
The Amplitude project's API Key.
5. protected String userId;
The user's User ID value.
6. protected String deviceId;
The user's Device ID value.
Constructor
public AmplitudeClient()
Instantiates a new AmplitudeClient
and starts worker threads.
Methods
1. public static AmplitudeClient getInstance()
Gets the default AmplitudeClient
instance.
Returns: The default instance.
2. public AmplitudeClient initialize(Context context, String apiKey)
Initialize the Amplitude SDK with the Android application context and your project's API Key in Amplitude. Note: Initialization is required before you log events and modify user properties.
Parameters:
context | The Android application context. |
apiKey | Your Amplitude project's API Key. |
Returns: The AmplitudeClient
.
3. public AmplitudeClient initialize(final Context context, final String apiKey, final String userId)
Initialize the Amplitude SDK with the Android application context, your project's API Key in Amplitude, and a User ID for the current user. Note: Initialization is required before you log events and modify user properties.
Parameters:
context | The Android application context. |
apiKey | Your Amplitude project's API Key. |
userId | The User ID to set. |
Returns: The AmplitudeClient
.
4. public AmplitudeClient enableForegroundTracking(Application app)
Enable foreground tracking SDK. IMPORTANT NOTE: This is highly recommended and will allow for accurate session tracking. See the Android SDK Installation documentation for more information on tracking sessions.
Parameters:
app | The Android application. |
Returns: The AmplitudeClient
.
5. public enableNewDeviceIdPerInstall(boolean newDeviceIdPerInstall)
Whether or not to set a new Device ID per install. If true
, then the SDK will always generate a new Device ID on app install as opposed to reusing an existing value like Google's AdID.
Returns: The AmplitudeClient
.
6. public AmplitudeClient useAdvertisingIdForDeviceId()
Whether to use the Android advertising ID (ADID) as the user's device ID.
Returns: The AmplitudeClient
.
7. public AmplitudeClient enableLocationListening()
Enable location listening in the SDK. This will add the user's current latitude and longitude coordinates to every event logged.
Returns: The AmplitudeClient
.
8. public AmplitudeClient disableLocationListening()
Disable location listening in the SDK. This will stop the SDK from sending the user's current latitude and longitude coordinates.
Returns: The AmplitudeClient
.
9. public AmplitudeClient setEventUploadThreshold(int eventUploadThreshold)
This sets the event upload threshold. The SDK will attempt to batch upload unset events every eventUploadPeriodMillis
milliseconds or if the unsent event count exceeds the event upload threshold.
Parameters:
eventUploadThreshold | The event upload threshold. |
Returns: The AmplitudeClient
.
10. public AmplitudeClient setEventUploadMaxBatchSize(int eventUploadMaxBatchSize)
This sets the event upload max batch size and controls the maximum number of events sent with each upload request.
Parameters:
eventUploadMaxBatchSize | The event upload max batch size. |
Returns: The AmplitudeClient
.
11. public AmplitudeClient setEventMaxCount(int eventMaxCount)
Sets the event max count. This is the maximum number of unsent events to keep on the device (for example, if the device does not have internet connectivity and cannot upload events). If the number of unset events exceeds the max count, then the SDK begins dropping events starting from the earliest logged.
Parameters:
eventMaxCount | The event max count. |
Returns: The AmplitudeClient
.
12. public setEventUploadPeriodMillis(int eventUploadPeriodMillis)
Sets the event upload period in milliseconds. The SDK will attempt to batch upload unset events every eventUploadPeriodMillis
milliseconds or if the unset event count exceeds the event upload threshold.
Parameters:
eventUploadPeriodMillis | The event upload period in milliseconds. |
Returns: The AmplitudeClient
.
13. public AmplitudeClient setMinTimeBetweenSessionsMillis(long minTimeBetweenSessionsMillis)
Sets the minimum time between sessions in milliseconds. Use this method to configure session tracking if you have foreground tracking enabled.
Parameters:
minTimeBetweenSessionsMillis | The minimum time between sessions in milliseconds. |
Returns: The minimum time between sessions in milliseconds.
14. public AmplitudeClient setSessionTimeoutMillis(long sessionTimeoutMillis)
Sets the session timeout in milliseconds. If foreground tracking has not been enabled with enabledForegroundTracking()
, then new sessions will be started after sessionTimeoutMillis
milliseconds have passed since the last event logged.
Parameters:
sessionTimeoutMillis | The session timeout in milliseconds. |
Returns: The AmplitudeClient
.
15. public AmplitudeClient setOptOut(final boolean optOut)
Sets whether or not to opt a user out logging. If this is true
, then the SDK will not track any events for the user.
Parameters:
optOut | Whether or not to opt the user out of tracking. |
Returns: The AmplitudeClient
.
16. public boolean isOptedOut()
Returns whether or not the user is opted out of tracking.
Returns: The optOut
flag value.
17. public AmplitudeClient enableLogging(boolean enableLogging)
Enable/disable message logging by the SDK.
Parameters:
enableLogging | Whether or not to enable message logging by the SDK. |
Returns: The AmplitudeClient
.
18. public AmplitudeClient setLogLevel(int logLevel)
Sets the logging level. Logging messages will only appear if they are the same severity level or higher than the set log level.
Parameters:
logLevel | The log level. |
Returns: The AmplitudeClient
.
19. public AmplitudeClient setOffline(boolean offline)
Sets offline. If offline is true
, then the SDK will not upload events to Amplitude's servers. However, it will still log events.
Parameters:
offline | Whether or not the SDK should be offline. |
Returns: The AmplitudeClient
.
20. public AmplitudeClient setFlushEventsOnClose(boolean flushEventsOnClose)
Enable/disable flushing of unsent events on app close. This is enabled by default.
Parameters:
flushEventsOnClose | Whether or not to flush unset events on app close. |
Returns: The AmplitudeClient
.
21. public AmplitudeClient trackSessionEvents(boolean trackingSessionEvents)
Track session events. If enabled, then the SDK will automatically send '[Amplitude] Start Session' and '[Amplitude] End Session' events to mark the start and end of the user's sessions. See the Android SDK Installation documentation for more information on tracking sessions.
Parameters:
trackingSessionEvents | Whether or not to enable tracking of session events. |
Returns: The AmplitudeClient
.
22. public void logEvent(String eventType)
Log an event with the specified event type. Note: This is asynchronous and happens on a background thread.
Parameters:
eventType | The event type. |
23. public void logEvent(String eventType, JSONObject eventProperties)
Log an event with the specified event type and event properties. Note: This is asynchronous and happens on a background thread. See the Android SDK Installation for more information on sending event properties.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
24. public void logEvent(String eventType, JSONObject eventProperties, boolean outOfSession)
Log an event with the specified event type and event properties with an optional out-of-session flag. Note: This might be useful when logging events for push notifications received. This is also asynchronous and happens on a background thread. If out-of-session is true
, then the sessionId
will be -1
for the event, indicating that it is not part of the current session. See the Android SDK Installation for more information on sending event properties and tracking sessions.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
outOfSession | The out-of-session flag. |
25. public void logEvent(String eventType, JSONObject eventProperties, JSONObject groups, long timestamp, boolean outOfSession)
Log an event with the specified event type, event properties, groups, and timestamp with an optional out-of-session flag. If out-of-session is true
, then the sessionId
will be -1
for the event indicating that it is not part of the current session. Note: This might be useful when logging events for push notifications received. This is also asynchronous and happens on a background thread. See the Android SDK Installation documentation for more information on setting event properties, setting groups, and tracking sessions.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
groups | The groups. |
timestamp | The timestamp in milliseconds since epoch. |
outOfSession | The out-of-session flag. |
26. public void logEventSync(String eventType)
Log an event with the specified event type. Note: This version of the method is synchronous and blocks the main thread until done.
Parameters:
eventType | The event type. |
27. public void logEventSync(String eventType, JSONObject eventProperties)
Log an event with the specified event type and event properties. Note: This version of the method is synchronous and blocks the main thread until done. See the Android SDK Installation for more information on sending event properties.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
28. public void logEventSync(String eventType, JSONObject eventProperties, boolean outOfSession)
Log an event with the specified event type and event properties with an optional out-of-session flag. Note: This might be useful when logging events for push notifications received. This version of the method is synchronous and blocks the main thread until done. See the Android SDK Installation for more information on sending event properties. If out-of-session is true
, then the sessionId
will be -1
for the event, indicating that it is not part of the current session. See the Android SDK Installation for more information on sending event properties and tracking sessions.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
outOfSession | The out-of-session flag. |
29. logEventSync(String eventType, JSONObject eventProperties, JSONObject groups, long timestamp, boolean outOfSession)
Log an event with the specified event type, event properties, groups, and timestamp with an optional out-of-session flag. If out-of-session is true
, then the sessionId
will be -1
for the event indicating that it is not part of the current session. Note: This might be useful when logging events for push notifications received. This version of the method is synchronous and blocks the main thread until done. See the Android SDK Installation documentation for more information on setting event properties, setting groups, and tracking sessions.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
groups | The groups. |
timestamp | The timestamp in milliseconds since epoch. |
outOfSession | The out-of-session flag. |
30. protected boolean validateLogEvent(String eventType)
Validate the event type being logged. This also verifies the context and the API Key have been set already with an initialize call.
Parameters:
eventType | The event type. |
Returns: True
if the event type is valid.
31. protected void logEventAsync(final String eventType, JSONObject eventProperties, final JSONObject apiProperties, JSONObject userProperties, JSONObject groups, final long timestamp, final boolean outOfSession)
Log an event asynchronously. This is an internal method to handle the synchronous logging of events.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
apiProperties | The API properties. |
userProperties | The user properties. |
groups | The groups. |
timestamp | The timestamp. |
outOfSession | The out-of-session flag. |
32. protected long logEvent(String eventType, JSONObject eventProperties, JSONObject apiProperties, JSONObject userProperties, JSONObject groups, long timestamp, boolean outOfSession)
Log an event. This is an internal method to handle the asynchronous logging of events on a background thread.
Parameters:
eventType | The event type. |
eventProperties | The event properties. |
apiProperties | The API properties. |
userProperties | The user properties. |
groups | The groups. |
timestamp | The timestamp. |
outOfSession | The out-of-session flag. |
Returns: The Event ID if successful, otherwise it will return -1
.
33. protected long saveEvent(String eventType, JSONObject event)
Save an event as a long
. This is an internal method to save an event to the database.
Parameters:
eventType | The event type. |
event | The event. |
Returns: The Event ID if successful, otherwise it will return -1
.
34. public long getSessionId()
Gets the current Session ID.
Returns: The current sessionId
value.
35. public void logRevenueV2(Revenue revenue)
Create a Revenue
object to hold your revenue data and properties. Then, log it as a revenue event using this method. See the Android SDK Installation documentation for more information on tracking revenue.
Parameters:
revenue | A Revenue object. |
36. public void setUserProperties(final JSONObject userProperties)
This sets user properties and is a convenience wrapper around the Identify API to set multiple user properties with a single command.
Parameters:
userProperties | The user properties. |
37. public void clearUserProperties()
This clears user properties and will clear all user properties at once. Note: The result is irreversible! See the Android SDK Installation documentation for more information on setting user properties.
38. public void identify(Identify identify)
Use this to send an Identify
object containing user property operations to Amplitude's servers. See the Android SDK Installation for more information on user property operations.
Parameters:
identify | An Identify object. |
39. public void identify(Identify identify, boolean outOfSession)
Use this to send an Identify
object containing user property operations to Amplitude's servers. If outOfSession
is set to true
, then the identify
event is sent with a Session ID of -1
and does not trigger any session-handling logic. See the Android SDK Installation documentation for more information on user property operations.
Parameters:
identify | An Identify object. |
outOfSession | Whether or not to log the identify event as out-of-session. |
40. public void setGroup(String groupType, Object groupName)
Sets the user's group(s). See the Android SDK Installation documentation for more information in setting groups.
Parameters:
groupType | The group type (e.g. 'orgId'). |
groupName | The group name (e.g. '15'). |
41. public JSONObject truncate(JSONObject object)
Truncate values in a JSON object. Any string values longer than 1024 characters will be truncated to 1024 characters. Any dictionary with more than 1000 items will be ignored.
Parameters:
object | The object. |
Returns: The truncated JSON object.
42. public String truncate(String value)
Truncate a string to 1024 characters.
Parameters:
value | the value. |
Returns: The truncated string.
43. public String getUserId()
Gets the user's User ID. This can be null
.
Returns: The developer specified identifier for tracking users.
44. public AmplitudeClient setUserId(final String userId)
This sets the User ID and can be null
.
Parameters:
userId | The User ID. |
Returns: The AmplitudeClient
.
45. public AmplitudeClient setDeviceId(final String deviceId)
This sets a custom Device ID. Note: Only do this if you know what you are doing! See the Android SDK Installation documentation for more information on setting custom Device IDs.
Parameters:
deviceId | The Device ID. |
Returns: The AmplitudeClient.
46. public AmplitudeClient regenerateDeviceId()
Regenerates a new random Device ID for the current user. Note: This is not recommended unless you know what you are doing. This can be used in conjunction with setUserId(null)
to anonymize users after they log out. With a null userId
and a completely new deviceId
, the current user would appear as a brand new user in Amplitude. See the Android SDK Installation for more information on logging out users.
47. public void uploadEvents()
Force the SDK to upload any unsent events.
48. protected void updateServer()
Internal method to upload unsent events.
49. protected void updateServer(boolean limit)
Internal method to upload unset events. The limit controls whether or not to use the event upload max batch size or backoff upload back size. Note: Always call this on logThread
.
Parameters:
deviceId | The Device ID. |
50. protected Pair<Pair<Long,Long>, JSONArray> mergeEventsAndIdentifys(List<JSONObject> events, List(JSONObject> identifys, long numEvents) throws JSONException
Internal method to merge unsent events and identifies into a single array by sequence number.
Parameters:
events | The events. |
identifys | The identify s. |
numEvents | The number of events. |
Returns: The merged array, maximum Event ID, and maximum identify
ID.
Throws: org.json.JSONException
, the JSON exception.
51. protected void makeEventUploadPostRequest(OkHttpClient client, String events, final long maxEventId, final long maxIdentifyId)
Internal method to generate the event upload post request.
Parameters:
client | The client. |
events | The events. |
maxEventId | The maximum Event ID. |
maxIdentifyId | The maximum identify ID. |
52. public String getDeviceId()
Get the current Device ID. This can be null if deviceId
hasn't been initialized yet.
Returns: A unique identifier for tracking with Amplitude.
53. protected void runOnLogThread(Runnable r)
54. protected Object replaceWithJSONNull(Object obj)
Internal method to replace null event fields with a JSON null object.
Parameters:
obj | The object. |
Returns: The object.
55. protected synchronized boolean contextAndApiKeySet(String methodName)
Internal method to check whether the application context and the API Key are set.
Parameters:
methodName | The parent method name to print in the error message. |
Returns: Whether or not the application context and API Key are set.
56. protected String bytesToHexString(byte[] bytes)
Internal method to convert bytes to a hex string.
Parameters:
bytes | The bytes. |
Returns: The string.
57. protected long getCurrentTimeMillis()
Internal method to fetch the current time in milliseconds. This is used for testing.
Returns: The current time in milliseconds.
Class: Identify
public class Identify extends java.lang.Object
Identify
objects are a wrapper for user property operations. Each method adds a user property operation to the Identify
object and returns the same Identify
object, allowing you to chain multiple method calls together. Here is an example:
Identify identify = new Identify().set("color", "green").add("karma", 1);
Note: If the same user property is used in multiple operations on a single Identify
object, only the first operation on that property will be saved and the rest will be ignored. After creating an Identify
object and setting the desired operations, sent it to Amplitude's servers by calling Amplitude.getInstance().identify(identify);
and pass in the object. See the Android SDK Installation documentation for more information on the Identify API and user property operations.
Fields
1. protected JSONObject userPropertiesOperations
Internal JSONObject
to hold all of the user property operations.
2. protected Set<String> userProperties
Internal set to keep track of user property keys and test for duplicates.
Constructor
public Identify()
Methods
1. public Identify setOnce(String property, value)
Sets a user property value only once. Subsequent setOnce
operations on that user property will be ignored.
Parameters:
property | The user property to setOnce . |
value | The value of the user property. This can be a boolean , double , float , int , long , java.lang.String , org.json.JSONArray , org.json.JSONObject , boolean[] , double[] , float[] , int[] , long[] , or java.lang.String[] . |
Returns: The same Identify
object.
2. public Identify set(String property, value)
Sets a user property value. Existing values for that user property will be overwritten.
Parameters:
property | The user property to set . |
value | The value of the user property. This can be a boolean , double , float , int , long , java.lang.String , org.json.JSONArray , org.json.JSONObject , boolean[] , double[] , float[] , int[] , long[] , or java.lang.String[] . |
Returns: The same Identify
object.
3. public Identify add(String property, value)
Increment a user property by some numerical value. If the user property does not have a value set, it will be initialized to 0
before being incremented. The value can also be negative to decrement a user property value.
Parameters:
property | The user property to increment. |
value | The value to increment. This can be a double , float , int , long , java.lang.String , or org.json.JSONObject . It can also be negative. |
Returns: The same Identify
object.
4. public Identify append(String property, value)
Append a value or values to a user property. If the user property does not have a value set, then it will be initialized to an empty list before the new values are appended. If the user property has an existing value and it is not a list, then it will be converted into a list with the new value(s) appended.
Parameters:
property | The user property with which to append. |
value | The value being appended. This can be a boolean , double , float , int , long , java.lang.String , org.json.JSONArray , boolean[] , double[] , float[] , int[] , long[] , java.lang.String[] , or org.json.JSONObject . |
Returns: The same Identify
object.
5. public Identify prepend(String property, value)
Prepend a value or values to a user property. Prepend means inserting the value(s) at the front of a given list. If the user property does not have a value set, then it will be initialized to an empty list before the new values are prepended. If the user property has an existing value and it is not a list, then it will be converted into a list with the new value(s) prepended.
Parameters:
property | The user property with which to prepend. |
value | The value being prepended. This can be a boolean , double , float , int , long , java.lang.String , org.json.JSONArray , boolean[] , double[] , float[] , int[] , long[] , java.lang.String[] , or org.json.JSONObject . |
Returns: The same Identify
object.
6. public Identify unset(String property)
Unset and remove a user property.
Parameters:
property | The user property to unset and remove. |
Returns: The same Identify
object.
7. public Identify clearAll()
Clear all user properties. Note: The result is irreversible. clearAll
also needs to be sent on its own Identify object without any other operations.
Returns: The same Identify
object.
Class: PinnedAmplitudeClient
public class PinnedAmplitudeClient extends AmplitudeClient
This is a version of the AmplitudeClient
class that supports SSL pinning for encrypted requests. Please contact Amplitude support here before you ship any products with SSL pinning enabled so that we are aware and can provide documentation and implementation help.
Fields
1. protected static final SSLContextBuilder SSL_CONTEXT_API_AMPLITUDE_COM
Pinned certificate chain for api.amplitude.com.
2. protected SSLSocketFactory sslSocketFactory;
The SSL socket factory.
Constructor
public PinnedAmplitudeClient(String instance)
Instantiates a new pinned AmplitudeClient
.
Methods
1. public static PinnedAmplitudeClient getInstance()
Gets the default instance and calls the SDK method on the default instance.
Returns: The default instance.
2. public synchronized AmplitudeClient initialize(Context context, String apiKey, String userId)
Initialize the Amplitude SDK with the Android application context, your Amplitude project's API Key, and a User ID for the current user. Note: Initialization is required before you log events and modify user properties.
Overrides: initialize
in class AmplitudeClient
.
Parameters:
context | The Android application context. |
apiKey | Your Amplitude project's API Key. |
userId | The User ID to set. |
Returns: The AmplitudeClient
.
3. protected SSLSocketFactory getPinnedCertSslSocketFactory()
Gets the pinned certificate SSL socket factory.
Returns: The pinned certificate SSL socket factory.
4. protected SSLSocketFactory getPinnedCertSslSocketFactory(SSLContextBuilder context)
Gets the pinned certificate SSL socket factory.
Parameters:
context | The context. |
Returns: The pinned certificate SSL socket factory.
Class: PinnedAmplitudeClient.SSLContextBuilder
protected static class PinnedAmplitudeClient.SSLContextBuilder extends java.lang.Object
SSL context builder that is used to generate the SSL context.
Constructor
protected SSLContextBuilder()
Methods
1. public SSLContextBuilder addCertificate(String certificateBase64)
Parameters:
certificateBase64 | The certificate base 64. |
Returns: The SSL context builder.
2. public SSLContext build()
Build SSL context.
Returns: The SSL context.
Class: Revenue
public class Revenue extends java.lang.Object
Revenue
objects are a wrapper for revenue events and revenue properties. This should be used in conjunction with AmplitudeClient.logRevenueV2()
to record in-app transactions. Each set method returns the same Revenue
object, allowing you to chain multiple set calls together. Here is an example:
Revenue revenue = new Revenue().setProductId("com.product.id").setPrice(3.99);
Note: price
is a required field. If quantity
is not specified, it will default to 1
. productId
, receipt
, and receiptSignature
are required if you want to verify the revenue event. Total revenue amount is also calculated as price * quantity.
After creating a Revenue
object and setting the desired transaction properties, send it to Amplitude's servers by calling Amplitude.getInstance().logRevenueV2(revenue);
and pass in the object. See the Android SDK Installation documentation for more information on logging revenue.
Fields
1. protected String productId (optional)
The product ID field.
2. protected int quantity (required)
The quantity field.
3. protected Double price (required)
The price field.
4. protected String revenueType (optional)
The revenue type field.
5. protected String receipt
(optional, required for revenue verification)
The receipt field.
6. protected String receiptSig
(optional, required for revenue verification)
The receipt signature field.
7. protected JSONObject properties
(optional)
The revenue event properties field.
Constructor
public Revenue()
Methods
1. protected boolean isValidRevenue()
Verifies that the revenue object is valid and contains the required fields.
Returns: true
if the revenue object is valid and false
otherwise.
2. public Revenue setProductId(String productId)
Sets a value for the product identifier. Empty and invalid strings are ignored.
Parameters:
productId | The product ID. |
Returns: The same Revenue
object.
3. public Revenue setQuantity(int quantity)
Sets a value for the quantity. Note: Revenue is calculated as price * quantity.
Parameters:
quantity | The quantity. |
Returns: The same Revenue
object.
4. public Revenue setPrice(double price)
Sets a value for the price. Note: Revenue is calculated as price * quantity.
Parameters:
price | The price. |
Returns: The same Revenue
object.
5. public Revenue setRevenueType(String revenueType)
Sets a value for the revenue type.
Parameters:
revenueType | The revenue type. |
Returns: The same Revenue
object.
6. public Revenue setReceipt(String receipt, String receiptSignature)
Sets the receipt and receipt signature. Both fields are required to verify the revenue event.
Parameters:
receipt | The receipt. |
receiptSignature | The revenue type. |
Returns: The same Revenue
object.
7. public Revenue setEventProperties(JSONObject eventProperties)
Set event properties for the revenue event, similarly to how event properties are set with logEvent
. See the Android SDK Installation documentation for more information on setting event properties.
Parameters:
eventProperties | The event properties. |
Returns: The same Revenue
object.
8. protected JSONObject toJSONObject()
Converts the Revenue
object into a JSONObject
to send to Amplitude's servers.
Returns: The JSON representation of this Revenue
object.
9. public boolean equals(Object o)
Custom equals function that compares two Revenue
objects. Two Revenue
objects are equal if all of their fields are equal.
Overrides: equals
in the class java.lang.Object
Parameters:
o | The other object to compare to. |
Returns: true
if the two Revenue
objects are equal and false
otherwise.
10. public int hashCode()
Custom hashcode generator function for the Revenue
object.
Overrides: hashcode
in the class java.lang.Object
Returns: The hashcode for this Revenue
instance.