本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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());
}
示例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);
}
}
示例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);
}
示例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());
}
示例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());
}
}
示例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();
}
示例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());
}
示例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));
}
示例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);
}
}
示例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);
}
示例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());
}
示例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);
}
}