public class ClientContext
extends java.lang.Object
ClientContext clientContext = new ClientContext(activity);
Map<String, String> map = new HashMap<String, String>();
map.put("first_name", "John");
map.put("last_name", "Doe");
clientContext.putCustomContext(map);
clientContext.putServiceContext("mobile_analytics", serviceContext);
String base64 = clientContext.toBase64String();
Constructor and Description |
---|
ClientContext(android.content.Context context)
Constructs a new client context.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getInstallationId(android.content.Context context)
Gets the installation id from shared preferences.
|
void |
putCustomContext(java.util.Map<java.lang.String,java.lang.String> map)
Adds additional user defined key-value pairs to the client context under
"custom".
|
void |
putServiceContext(java.lang.String service,
java.util.Map<java.lang.String,java.lang.String> map)
Sets service context under key "services".
|
java.lang.String |
toBase64String()
Serializes the client context into a base64 encoded Json string.
|
public ClientContext(android.content.Context context)
context
- context of the apppublic static java.lang.String getInstallationId(android.content.Context context)
context
- context of the apppublic void putCustomContext(java.util.Map<java.lang.String,java.lang.String> map)
Map<String, String> map = new HashMap<String, String>();
map.put("first_name", "John");
map.put("last_name", "Doe");
clientContext.putCustomContext(map);
The above code will add a Json object under "custom" as following.
{ "custom": { "first_name":"John", "last_name":"Doe" } }
map
- the custom key-value context mappublic void putServiceContext(java.lang.String service, java.util.Map<java.lang.String,java.lang.String> map)
{ "services": { "mobile_analytics": { "app_id":"mobile_analytics_app_id" } } }
service
- service namemap
- the service key-value context mappublic java.lang.String toBase64String()
Copyright © 2018 Amazon Web Services, Inc. All Rights Reserved.