當前位置: 首頁>>代碼示例>>Java>>正文


Java HitBuilders.ExceptionBuilder方法代碼示例

本文整理匯總了Java中com.google.android.gms.analytics.HitBuilders.ExceptionBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Java HitBuilders.ExceptionBuilder方法的具體用法?Java HitBuilders.ExceptionBuilder怎麽用?Java HitBuilders.ExceptionBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.analytics.HitBuilders的用法示例。


在下文中一共展示了HitBuilders.ExceptionBuilder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: logGoogleAnalyticsEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private void logGoogleAnalyticsEvent(AnalyticsEvent event)
{
	if (event instanceof ContentViewEvent)
	{
		HitBuilders.ScreenViewBuilder screenViewBuilder = new HitBuilders.ScreenViewBuilder();
		// add any custom attributes already set on the event
		screenViewBuilder.setAll(stringifyAttributesMap(event.getAttributes()));

		synchronized (this.tracker)
		{
			// Set the screen name and send a screen view.
			this.tracker.setScreenName(String.valueOf(event.getAttribute(ContentViewEvent.CONTENT_NAME)));
			this.tracker.send(screenViewBuilder.build());
		}
	}
	else if (event instanceof ErrorEvent)
	{
		ErrorEvent errorEvent = (ErrorEvent) event;
		// Build and send exception.
		HitBuilders.ExceptionBuilder exceptionBuilder = new HitBuilders.ExceptionBuilder()
				.setDescription(errorEvent.message())
				.setFatal(false);

		// Add any custom attributes that are attached to the event
		exceptionBuilder.setAll(stringifyAttributesMap(errorEvent.getAttributes()));

		this.tracker.send(exceptionBuilder.build());
	}
	else
	{
		// Build and send an Event.
		HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
				.setCategory("User Event")
				.setAction(event.name());

		// Add any custom attributes that are attached to the event
		eventBuilder.setAll(stringifyAttributesMap(event.getAttributes()));

		this.tracker.send(eventBuilder.build());
	}
}
 
開發者ID:busybusy,項目名稱:AnalyticsKit-Android,代碼行數:42,代碼來源:GoogleAnalyticsProvider.java


注:本文中的com.google.android.gms.analytics.HitBuilders.ExceptionBuilder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。