use of com.microsoft.azure.mobile.ingestion.models.LogWithProperties in project mobile-center-sdk-android by Microsoft.
the class MainActivity method getAnalyticsListener.
private AnalyticsListener getAnalyticsListener() {
return new AnalyticsListener() {
@Override
public void onBeforeSending(com.microsoft.azure.mobile.ingestion.models.Log log) {
if (log instanceof EventLog) {
Toast.makeText(MainActivity.this, R.string.event_before_sending, Toast.LENGTH_SHORT).show();
} else if (log instanceof PageLog) {
Toast.makeText(MainActivity.this, R.string.page_before_sending, Toast.LENGTH_SHORT).show();
}
analyticsIdlingResource.increment();
}
@Override
public void onSendingFailed(com.microsoft.azure.mobile.ingestion.models.Log log, Exception e) {
String message = null;
if (log instanceof EventLog) {
message = getString(R.string.event_sent_failed);
} else if (log instanceof PageLog) {
message = getString(R.string.page_sent_failed);
}
if (message != null) {
message = String.format("%s\nException: %s", message, e.toString());
Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
}
analyticsIdlingResource.decrement();
}
@Override
public void onSendingSucceeded(com.microsoft.azure.mobile.ingestion.models.Log log) {
String message = null;
if (log instanceof EventLog) {
message = String.format("%s\nName: %s", getString(R.string.event_sent_succeeded), ((EventLog) log).getName());
} else if (log instanceof PageLog) {
message = String.format("%s\nName: %s", getString(R.string.page_sent_succeeded), ((PageLog) log).getName());
}
if (message != null) {
if (((LogWithProperties) log).getProperties() != null) {
message += String.format("\nProperties: %s", new JSONObject(((LogWithProperties) log).getProperties()).toString());
}
Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
}
analyticsIdlingResource.decrement();
}
};
}
Aggregations