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


Java HitBuilders.EventBuilder方法代碼示例

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


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

示例1: buildUserEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
/**
 * Will create an event builder based on the passed variables.
 * @param category - category of event
 * @param action - action of event
 * @param label - label of event
 * @param customDimension1 - custom dimension of event
 * @param customDimension2 - custom dimension of event
 * @return - the created Event Builder for analytics
 */
private static HitBuilders.EventBuilder buildUserEvent(String category, String action, String label,
                                                       @Nullable String customDimension1, @Nullable String customDimension2) {

    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
            .setCategory(category)
            .setAction(action)
            .setLabel(label)
            .setValue(1);

    // Set custom dimensions
    if (!TextUtils.isEmpty(customDimension1)) {
        eventBuilder.setCustomDimension(1, customDimension1);
    }
    if (!TextUtils.isEmpty(customDimension2)) {
        eventBuilder.setCustomDimension(2, customDimension2);
    }

    return eventBuilder;
}
 
開發者ID:smashingboxes,項目名稱:android-analytics,代碼行數:29,代碼來源:TrackerManager.java

示例2: sendEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
/**
 * Log a specific event under the {@code category}, {@code action}, and {@code label}.
 */
public static void sendEvent(String category, String action, String label, long value,
                             HitBuilders.EventBuilder eventBuilder) {
    if(isInitialized()) {
        mTracker.send(eventBuilder
                .setCategory(category)
                .setAction(action)
                .setLabel(label)
                .setValue(value)
                .build());

        LOGD(TAG, "Event recorded: \n" +
                "\tCategory: " + category +
                "\tAction: " + action +
                "\tLabel: " + label +
                "\tValue: " + value);
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:21,代碼來源:AnalyticsHelper.java

示例3: savePreferences

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private void savePreferences(final String prefKey, final boolean isPositiveResponse) {
    if (mCheckbox != null) {
        final SharedPreferences.Editor editor = mPrefs.prefs.edit();
        final boolean dontShow = mCheckbox.isChecked();
        if (dontShow) {
            Toast.makeText(getActivity(), R.string.pref_dialog_selection_reset_desc, Toast.LENGTH_LONG).show();
            editor.putString(prefKey,
                    getString(isPositiveResponse ? PREFERENCE_ALWAYS_ID : PREFERENCE_NEVER_ID));
        } else {
            editor.putString(prefKey, getString(PREFERENCE_ASK_ID));
        }

        editor.apply();

        HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
                .setCategory(GAUtils.Category.PREFERENCE_DIALOGS)
                .setAction(getArguments().getString(EXTRA_TITLE))
                .setLabel("Response: " + (isPositiveResponse ? "Yes" : "No") + (dontShow ?
                        " (Always)" : " (Just once)"));
        GAUtils.sendEvent(eventBuilder);
    }
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:23,代碼來源:SupportYesNoWithPrefsDialog.java

示例4: doTrackEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private void doTrackEvent(
    String aCategory, String aAction, String aLabel, Long aValue) {

    HitBuilders.EventBuilder hit = new HitBuilders.EventBuilder()
        .setCategory(aCategory)
        .setAction(aAction);

    if (aLabel != null) {
        hit.setLabel(aLabel);
    }

    if (aValue != null) {
        hit.setValue(aValue.longValue());
    }

    mTracker.send(hit.build());
}
 
開發者ID:mozilla-magnet,項目名稱:magnet-client,代碼行數:18,代碼來源:Analytics.java

示例5: savePreferences

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private void savePreferences(final String prefKey, final boolean isPositiveResponse){
    if(mCheckbox != null) {
        final SharedPreferences.Editor editor = mPrefs.prefs.edit();
        final boolean dontShow = mCheckbox.isChecked();
        if(dontShow){
            Toast.makeText(getActivity(), R.string.pref_dialog_selection_reset_desc, Toast.LENGTH_LONG).show();
                    editor.putString(prefKey,
                            getString(isPositiveResponse ? PREFERENCE_ALWAYS_ID : PREFERENCE_NEVER_ID));
        }
        else{
            editor.putString(prefKey, getString(PREFERENCE_ASK_ID));
        }

        editor.apply();

        HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
                .setCategory(GAUtils.Category.PREFERENCE_DIALOGS)
                .setAction(getArguments().getString(EXTRA_TITLE))
                .setLabel("Response: " + (isPositiveResponse ? "Yes" : "No") + (dontShow ?
                        " (Always)" : " (Just once)"));
        GAUtils.sendEvent(eventBuilder);
    }
}
 
開發者ID:jiaminghan,項目名稱:droidplanner-master,代碼行數:24,代碼來源:YesNoWithPrefsDialog.java

示例6: sendEventWithCustomDimension

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
/**
 * Log an specific event under the {@code category}, {@code action}, and {@code label}.  Attach
 * a custom dimension using the provided {@code dimensionIndex} and {@code dimensionValue}
 */
public static void sendEventWithCustomDimension(String category, String action, String label,
                                                int dimensionIndex, String dimensionValue) {
    // Create a new HitBuilder, populate it with the custom dimension, and send it along
    // to the rest of the event building process.
    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder();
    eventBuilder.setCustomDimension(dimensionIndex, dimensionValue);
    sendEvent(category, action, label, 0, eventBuilder);

    LOGD(TAG, "Custom Dimension Attached:\n" +
            "\tindex: " + dimensionIndex +
            "\tvalue: " + dimensionValue);
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:17,代碼來源:AnalyticsHelper.java

示例7: sendEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private void sendEvent(final String screenName, final String category, final String action, final HashMap<Integer, String> dimensionsMap) {
    mTracker.setScreenName(screenName);

    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
            .setCategory(category)
            .setAction(action);

    for (int key : dimensionsMap.keySet()) {
        eventBuilder.setCustomDimension(key, dimensionsMap.get(key));
    }

    mTracker.send(eventBuilder.build());
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:14,代碼來源:GoogleAnalyticsManager.java

示例8: trackEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
public void trackEvent(String category, String action, @Nullable String label, @Nullable Long value) {
	HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder().setCategory(category).setAction(action);

	if (label != null) {
		builder.setLabel(label);
	}

	if (value != null) {
		builder.setValue(value);
	}

	if (mTracker != null) {
		mTracker.send(builder.build());
	}
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:16,代碼來源:UsageTrackingAppCompatActivity.java

示例9: parsePayload

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private Map<String, String> parsePayload(Map<String, Object> analyticsPayload) {
    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder();

    //TODO Should this be protected, or crash in purpose to avoid mistakes on dev side?
    if (analyticsPayload.containsKey(CATEGORY)) {
        eventBuilder.setCategory((String) analyticsPayload.get(CATEGORY));
    }

    if (analyticsPayload.containsKey(ACTION)) {
        eventBuilder.setCategory((String) analyticsPayload.get(ACTION));
    }
    if (analyticsPayload.containsKey(LABEL)) {
        eventBuilder.setLabel((String) analyticsPayload.get(LABEL));
    }

    if (analyticsPayload.containsKey(VALUE)) {
        eventBuilder.setValue((Long) analyticsPayload.get(VALUE));
    }

    if (analyticsPayload.containsKey(PRODUCT)) {
        eventBuilder.addProduct((Product) analyticsPayload.get(PRODUCT));
    }

    if (analyticsPayload.containsKey(PRODUCT_ACTION)) {
        eventBuilder.setProductAction((ProductAction) analyticsPayload.get(PRODUCT_ACTION));
    }

    return eventBuilder.build();
}
 
開發者ID:Mindera,項目名稱:skeletoid-googleanalytics,代碼行數:30,代碼來源:GAAppender.java

示例10: trackGoogleAnalytics

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private void trackGoogleAnalytics(String category, String action, String label) {
    // Google Analytics
    HitBuilders.EventBuilder gaEventBuilder = new HitBuilders.EventBuilder();

    gaEventBuilder.setCategory(category);
    gaEventBuilder.setAction(action);
    gaEventBuilder.setLabel(label);

    mTracker.send(gaEventBuilder.build());
}
 
開發者ID:sinhaDroid,項目名稱:BlogBookApp,代碼行數:11,代碼來源:BlogBookAnalytics.java

示例11: sendEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
/**
 * Базовый метод для отправки события c параметрами
 *
 * @param
 * @param category категория
 * @param action   действие
 * @param label    пометка о результате действия
 * @param pair
 */
public static void sendEvent(String category, String action, String label, Map<String, String> pair) {
    Tracker tracker = AGApplication.getTracker();
    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder();
    eventBuilder.setAction(action)
            .setCategory(category)
            .setLabel(label)
            .setValue(1)
            .setAll(pair);
    tracker.send(eventBuilder.build());
    Log.i("AG_Google_Analytics", "action = " + action + ", category = " + category + ", label = " + label + ", " + getMapLog(pair));
}
 
開發者ID:active-citizen,項目名稱:android.java,代碼行數:21,代碼來源:GoogleStatistics.java

示例12: onReceive

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
	final String action = intent.getAction();
	if (AttributeEvent.AUTOPILOT_FAILSAFE.equals(action)) {
		final HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
				.setCategory(GAUtils.Category.FAILSAFE).setAction("Autopilot warning")
				.setLabel(drone.getState().getFailsafeWarning());
		GAUtils.sendEvent(eventBuilder);
	}
}
 
開發者ID:jiaminghan,項目名稱:droidplanner-master,代碼行數:11,代碼來源:NotificationHandler.java

示例13: recordFileImport

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
private boolean recordFileImport(SQLiteDatabase db, ContentValues importDetails) {
    // First tell Google Analytics
    final String fileName = importDetails.getAsString(FILE_IDENTIFIER);
    HitBuilders.EventBuilder fileImportValues = new HitBuilders.EventBuilder()
            .setAction("FileImport")
            .setCategory("LOCAL")
            .setLabel(fileName)
            .setValue(1)
            .setCustomDimension(1, fileName);
    mTracker.send(fileImportValues.build());

    // Now record the full details locally.
    final long rowId = db.insert(FILE_IMPORT, null, importDetails);
    return (rowId != -1);
}
 
開發者ID:julianharty,項目名稱:app-store-reviews-app,代碼行數:16,代碼來源:LoadReviewsActivity.java

示例14: reportEvent

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
public void reportEvent(Tracking.Events event, String label) {
    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
            .setCategory(context.getString(event.category))
            .setAction(context.getString(event.action));
    if (!Strings.isNullOrEmpty(label)) {
        eventBuilder.setLabel(label);
    }
    tracker.send(eventBuilder.build());
}
 
開發者ID:andyCano,項目名稱:TaskApp,代碼行數:10,代碼來源:Tracker.java

示例15: onAutopilotError

import com.google.android.gms.analytics.HitBuilders; //導入方法依賴的package包/類
public void onAutopilotError(String errorName) {
    final ErrorType errorType = ErrorType.getErrorById(errorName);
    if (errorType != null && ErrorType.NO_ERROR != errorType) {
        final HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
                .setCategory(GAUtils.Category.FAILSAFE)
                .setAction("Autopilot error")
                .setLabel(errorType.getLabel(context).toString());
        GAUtils.sendEvent(eventBuilder);
    }
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:11,代碼來源:NotificationHandler.java


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