public class CustomEvent extends AsyncTask<Void, Integer, String> {
private HashMap<String, Object> customEvent;
private CleverTapAPI cleverTap = null;
private String val1, val2;
private Context context;
public CustomEvent(Context context, String myValue1, String myValue2) {
this.context = context;
val1 = myValue1;
val2 = myValue2;
}
protected String doInBackground(Void... arg0) {
try {
cleverTap = CleverTapAPI.getInstance(context);
} catch (CleverTapMetaDataNotFoundException e) {
// handle appropriately
} catch (CleverTapPermissionsNotSatisfied e) {
// handle appropriately
}
customEvent = new HashMap<String, Object>();
if (val1 != null)
customEvent.put("val1", val1);
if (val2 != null) customEvent.put("val2", val2);
customEvent.put("id", "1");
cleverTap.event.push("My Event", customEvent);
return null;
}
}