public class ClientContext extends 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 String |
getInstallationId(android.content.Context context)
Gets the installation id from shared preferences.
|
void |
putCustomContext(Map<String,String> map)
Adds additional user defined key-value pairs to the client context under
"custom".
|
void |
putServiceContext(String service,
Map<String,String> map)
Sets service context under key "services".
|
String |
toBase64String()
Serializes the client context into a base64 encoded Json string.
|
public ClientContext(android.content.Context context)
context - context of the apppublic static String getInstallationId(android.content.Context context)
context - context of the apppublic void putCustomContext(Map<String,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(String service, Map<String,String> map)
{
"services": {
"mobile_analytics": {
"app_id":"mobile_analytics_app_id"
}
}
}
service - service namemap - the service key-value context mappublic String toBase64String()
Copyright © 2018. All rights reserved.