com.google.android.gms.analytics.HitBuilders Java Examples

The following examples show how to use com.google.android.gms.analytics.HitBuilders. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IssueActivity.java    From android with MIT License 6 votes vote down vote up
private void sendShare() {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(
            R.string.issue_share_subject));
    shareIntent.putExtra(Intent.EXTRA_TEXT,
            String.format(getResources().getString(R.string.issue_share_content), mIssue.name,
                    mIssue.id));
    shareIntent.setType("text/plain");

    if (mTracker != null) {
        mTracker.send(new HitBuilders.EventBuilder()
                .setCategory("Share")
                .setAction("IssueShare")
                .setLabel(mIssue.id)
                .setValue(1)
                .build());
    }

    startActivity(Intent.createChooser(shareIntent, getResources().getString(
            R.string.share_chooser_title)));
}
 
Example #2
Source File: Analytics.java    From openshop.io-android with MIT License 6 votes vote down vote up
/**
 * Method sends "category view" event to Google Analytics.
 *
 * @param categoryId   id category for logging.
 * @param categoryName category name for logging.
 * @param isSearch     determine if normal category or search category.
 */
public static void logCategoryView(long categoryId, String categoryName, boolean isSearch) {
    Bundle parameters = new Bundle();
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "category");

    if (categoryId == 0) {
        Timber.e("Is categoryId = 0.");
    } else {
        parameters.putLong(AppEventsConstants.EVENT_PARAM_CONTENT_ID, categoryId);
        parameters.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, categoryName);
        logFbEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT, null, parameters);

        Map<String, String> event = new HitBuilders.EventBuilder()
                .setCategory("VIEW_CATEGORY")
                .setAction(isSearch ? "SEARCH" : "VIEW_CATEGORY")
                .setLabel(isSearch ? "Search: " + categoryName : "CategoryId: " + categoryId + ". CategoryName: " + categoryName)
                .build();

        sendEventToAppTrackers(event);
    }
}
 
Example #3
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
@Subscribe
public void onVolumePanelChangeEvent(VolumeAccessibilityService.VolumePanelChangeEvent event) {
    LOGI(TAG, "onVolumePanelChangeEvent(" + event.getName() + ')');
    boolean rControllerEnabled = Utils.isMediaControllerEnabled(this);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2 &&
        event.supportsMediaPlayback() && !isFinishing() &&
        !rControllerEnabled) {
        NotificationFragment fragment = NotificationFragment.getInstance(false);
        if (null != fragment && null == getFragmentManager().findFragmentByTag(NotificationFragment.class.getSimpleName())) {
            fragment.show(getFragmentManager(), NotificationFragment.class.getSimpleName());
        }
    }

    // TRACK: what theme is being used.
    if (NoyzeApp.GOOGLE_ANALYTICS) {
        Tracker t = ((NoyzeApp) getApplication()).getTracker(
                NoyzeApp.TrackerName.APP_TRACKER);
        t.send(new HitBuilders.EventBuilder()
                .setCategory("Setting")
                .setAction("Change")
                .setLabel(event.getName())
                .build());
    }
}
 
Example #4
Source File: MainActivity.java    From miracast-widget with Apache License 2.0 6 votes vote down vote up
private void startSettingsActivity(Intent intent) {
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    try {
        startActivity(intent);
    } catch (SecurityException e) {
        // We don't have permission to launch this activity, alert the user and return.
        showErrorToast();

        mTracker.send(new HitBuilders.ExceptionBuilder()
                            .setDescription("SecurityException launching intent: "
                                    + intent.getAction()
                                    + ", "
                                    + intent.getComponent())
                            .setFatal(false)
                            .build());
        sendEvent(CATEGORY_CAST_LAUNCH, ACTION_ERROR, "security_exception");
        return;
    }
}
 
Example #5
Source File: BarometerNetworkActivity.java    From PressureNet with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onStart() {
	dataReceivedToPlot = false;
	// bindCbService();
	super.onStart();
	log("barometernetworkactivity onstart");
	// Get tracker.
	Tracker t = ((PressureNetApplication) getApplication()).getTracker(
	    TrackerName.APP_TRACKER);


	// Set screen name.
	t.setScreenName("PressureNet Main App");

	// Send a screen view.
	t.send(new HitBuilders.ScreenViewBuilder().build());
}
 
Example #6
Source File: MyApp.java    From cute-pets-example-android-app with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    analytics = GoogleAnalytics.getInstance(this);

    // TODO: Replace the tracker-id with your app one from https://www.google.com/analytics/web/
    tracker = analytics.newTracker("UA-54478999-3");

    // Provide unhandled exceptions reports. Do that first after creating the tracker
    tracker.enableExceptionReporting(true);

    // Enable Remarketing, Demographics & Interests reports
    // https://developers.google.com/analytics/devguides/collection/android/display-features
    tracker.enableAdvertisingIdCollection(true);

    // Enable automatic activity tracking for your app
    tracker.enableAutoActivityTracking(true);

    tracker.send(new HitBuilders.ScreenViewBuilder().setCustomDimension(1, null).build());
}
 
Example #7
Source File: TrailerList.java    From moviedb-android with Apache License 2.0 6 votes vote down vote up
/**
 * Called to have the fragment instantiate its user interface view.
 *
 * @param inflater           sets the layout for the current view.
 * @param container          the container which holds the current view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous saved state as given here.
 *                           Return the View for the fragment's UI, or null.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);


    View rootView;
    rootView = inflater.inflate(R.layout.gallerylist, container, false);
    listView = (AbsListView) rootView.findViewById(R.id.gridView);
    activity = ((MainActivity) getActivity());

    Tracker t = ((MovieDB) activity.getApplication()).getTracker();
    t.setScreenName("TrailerList - " + getTitle());
    t.send(new HitBuilders.ScreenViewBuilder().build());

    return rootView;
}
 
Example #8
Source File: NavigationDrawerFragment.java    From IdealMedia with Apache License 2.0 6 votes vote down vote up
private void sendSupportMail() {
    final Intent intent = new Intent(Intent.ACTION_SENDTO);

    intent.setType("message/rfc822");
    intent.setData(Uri.parse(String.format("mailto:%s?subject=%s", getString(R.string.support_email), Uri.encode(getString(R.string.app_name)))));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    try {
        startActivity(intent);

        ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                .send(new HitBuilders.EventBuilder().setCategory("Support").setAction("Send").setLabel("Yes").build());
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(getActivity(), getString(R.string.no_email_client), Toast.LENGTH_SHORT).show();
        ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                .send(new HitBuilders.EventBuilder().setCategory("Support").setAction("Send").setLabel("Error").build());
    }
}
 
Example #9
Source File: Analytics.java    From magnet-client with Mozilla Public License 2.0 6 votes vote down vote up
private void doTrackTiming(String aCategory, Double aValue,
    String aName, String aLabel) {

    HitBuilders.TimingBuilder hit = new HitBuilders.TimingBuilder()
        .setCategory(aCategory)
        .setValue(aValue.longValue());

    if (aName != null) {
        hit.setVariable(aName);
    }

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

    mTracker.send(hit.build());
}
 
Example #10
Source File: AnalyticsTracker.java    From AJShA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void trackEvent(String category, String action, String label, Long val) {
    final HitBuilders.EventBuilder eventMapBuilder = new HitBuilders.EventBuilder();

    if (category != null) {
        eventMapBuilder.setCategory(category);
    }

    if (action != null) {
        eventMapBuilder.setAction(action);
    }

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

    if (val != null) {
        eventMapBuilder.setValue(val);
    }

    tracker.send(eventMapBuilder.build());
}
 
Example #11
Source File: TelecineShortcutConfigureActivity.java    From Telecine with Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  AndroidInjection.inject(this);
  super.onCreate(savedInstanceState);

  analytics.send(new HitBuilders.EventBuilder() //
      .setCategory(Analytics.CATEGORY_SHORTCUT) //
      .setAction(Analytics.ACTION_SHORTCUT_ADDED) //
      .build());

  Intent launchIntent = new Intent(this, TelecineShortcutLaunchActivity.class);
  ShortcutIconResource icon = ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);

  Intent intent = new Intent();
  intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_name));
  intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
  intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);

  setResult(RESULT_OK, intent);
  finish();
}
 
Example #12
Source File: Analytics.java    From openshop.io-android with MIT License 6 votes vote down vote up
/**
 * Method sends product view event to defined Analytics.
 *
 * @param remoteId remote id of the viewed product.
 * @param name     name of the viewed product.
 */
public static void logProductView(long remoteId, String name) {
    // FB event log
    Bundle parameters = new Bundle();
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, PRODUCT);
    parameters.putLong(AppEventsConstants.EVENT_PARAM_CONTENT_ID, remoteId);
    parameters.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, name);
    logFbEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT, null, parameters);

    // GA event log
    Map<String, String> event = new HitBuilders.EventBuilder()
            .setCategory(PRODUCT)
            .setAction("view")
            .setLabel("product with id: " + remoteId + ", name: " + name)
            .build();
    sendEventToAppTrackers(event);
}
 
Example #13
Source File: Analytics.java    From magnet-client with Mozilla Public License 2.0 6 votes vote down vote up
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());
}
 
Example #14
Source File: TelecineShortcutLaunchActivity.java    From Telecine with Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  AndroidInjection.inject(this);
  super.onCreate(savedInstanceState);

  String launchAction = getIntent().getStringExtra(KEY_ACTION);
  if (launchAction == null) {
    launchAction = Analytics.ACTION_SHORTCUT_LAUNCHED;
  }

  analytics.send(new HitBuilders.EventBuilder() //
      .setCategory(Analytics.CATEGORY_SHORTCUT)
      .setAction(launchAction)
      .build());

  CaptureHelper.fireScreenCaptureIntent(this, analytics);
}
 
Example #15
Source File: OneSignalNotificationController.java    From android with MIT License 6 votes vote down vote up
public static void setUp(final FiveCallsApplication application) {
    OneSignal.startInit(application)
            .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
            .setNotificationOpenedHandler(new OneSignal.NotificationOpenedHandler() {
                @Override
                public void notificationOpened(OSNotificationOpenResult result) {
                    // Check whether notifications are allowed when the item is clicked.
                    if (AccountManager.Instance.allowAnalytics(
                            application.getApplicationContext())) {
                        Tracker tracker = application.getDefaultTracker();
                        tracker.send(new HitBuilders.EventBuilder()
                                .setCategory("Notifications")
                                .setAction("LaunchFromNotification")
                                .setValue(1)
                                .build());
                    }
                }
            })
            .disableGmsMissingPrompt(true) // We won't worry about out-of-date GMS
            .unsubscribeWhenNotificationsAreDisabled(true)
            .init();
    // Disable notifications if we haven't prompted the user about them yet.
    if (!AccountManager.Instance.isNotificationDialogShown(application)) {
        OneSignal.setSubscription(false);
    }
}
 
Example #16
Source File: CourseActivity.java    From KUAS-AP-Material with MIT License 6 votes vote down vote up
private void showCourseDialog(final int weekday, final int section) {
	mTracker.send(new HitBuilders.EventBuilder().setCategory("show course").setAction("click")
			.setLabel(mList.get(weekday).get(section).title).build());

	String instructors = mList.get(weekday).get(section).instructors.size() > 0 ?
			mList.get(weekday).get(section).instructors.get(0) : "";
	for (int k = 1; k < mList.get(weekday).get(section).instructors.size(); k++) {
		instructors += "," + mList.get(weekday).get(section).instructors.get(k);
	}

	String start_time = !mList.get(weekday).get(section).start_time.contains(":") ?
			getResources().getStringArray(R.array.start_time)[section] :
			mList.get(weekday).get(section).start_time;
	String end_time = !mList.get(weekday).get(section).end_time.contains(":") ?
			getResources().getStringArray(R.array.end_time)[section] :
			mList.get(weekday).get(section).end_time;

	new AlertDialog.Builder(CourseActivity.this).setTitle(R.string.course_dialog_title)
			.setMessage(getString(R.string.course_dialog_messages,
					mList.get(weekday).get(section).title, instructors,
					mList.get(weekday).get(section).room, start_time +
							" - " + end_time)).setPositiveButton(R.string.ok, null).show();
}
 
Example #17
Source File: BusReservationsActivity.java    From KUAS-AP-Material with MIT License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
	mTracker.send(new HitBuilders.EventBuilder().setCategory("cancel bus").setAction("create")
			.build());
	boolean index = mList.get(position).endStation.equals("燕巢");
	new AlertDialog.Builder(this).setTitle(R.string.bus_cancel_reserve_confirm_title)
			.setMessage(getString(R.string.bus_cancel_reserve_confirm_content,
					getString(index ? R.string.bus_from_jiangong : R.string.bus_from_yanchao),
					mList.get(position).runDateTime))
			.setPositiveButton(R.string.bus_cancel_reserve,
					new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							mTracker.send(
									new HitBuilders.EventBuilder().setCategory("cancel bus")
											.setAction("click").build());
							cancelBookBus(mList, position);
						}
					}).setNegativeButton(R.string.back, null).show();
}
 
Example #18
Source File: Analytics.java    From openshop.io-android with MIT License 6 votes vote down vote up
/**
 * Method sends "product add to cart" event to defined Analytics.
 *
 * @param remoteId       remote id of the viewed product.
 * @param name           name of the viewed product.
 * @param discountPrice product price.
 */
public static void logAddProductToCart(long remoteId, String name, double discountPrice) {
    // FB facebookLogger
    Bundle parameters = new Bundle();
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, PRODUCT);
    parameters.putLong(AppEventsConstants.EVENT_PARAM_CONTENT_ID, remoteId);
    parameters.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, name);
    logFbEvent(AppEventsConstants.EVENT_NAME_ADDED_TO_CART, discountPrice, parameters);

    // Ga
    Map<String, String> event = new HitBuilders.EventBuilder()
            .setCategory("ADDED_TO_CART")
            .setAction("ADDED_TO_CART")
            .setLabel("ADDED TO CART" + " product id: " + remoteId + " product name: " + name + " price: " + discountPrice)
            .build();
    sendEventToAppTrackers(event);
}
 
Example #19
Source File: Stats.java    From materialup with Apache License 2.0 5 votes vote down vote up
public void track(String name) {
    if (mTracker == null) {
        getDefaultTracker(App.getIns());
    }
    mTracker.setScreenName(name);
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
 
Example #20
Source File: EditLocationActivity.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onStart() {
	// Get tracker.
	Tracker t = ((PressureNetApplication) getApplication())
			.getTracker(TrackerName.APP_TRACKER);
	// Set screen name.
	t.setScreenName("Edit Location");

	// Send a screen view.
	t.send(new HitBuilders.ScreenViewBuilder().build());
	super.onStart();
}
 
Example #21
Source File: Stats.java    From materialup with Apache License 2.0 5 votes vote down vote up
public void track(String cat, String name) {
    if (mTracker == null) {
        getDefaultTracker(App.getIns());
    }
    mTracker.send(new HitBuilders.EventBuilder()
            .setCategory(cat)
            .setAction(name)
            .build());
}
 
Example #22
Source File: AnalyticsHelper.java    From talk-android with MIT License 5 votes vote down vote up
private void sendGAEvent(String category, String action, String label) {
    try {
        HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder();
        builder.setCategory(category)
                .setAction(action);
        if (StringUtil.isNotBlank(label)) {
            builder.setLabel(label);
        }
        googleTracker.send(builder.build());
    } catch (Exception e) {
        Logger.e("AnalyticsHelper", "parse categoryId failed", e.getCause());
    }
}
 
Example #23
Source File: AnalyticsHelper.java    From talk-android with MIT License 5 votes vote down vote up
public void endTiming(Category category, String action) {
    if (shouldSendEvent()) return;

    long startTime = timingStartTimeMap.containsKey(category + action)
            ? timingStartTimeMap.get(category + action) : System.currentTimeMillis();
    long interval = System.currentTimeMillis() - startTime;

    googleTracker.send(new HitBuilders.TimingBuilder()
            .setCategory(category.name)
            .setValue(interval)
            .setVariable(action)
            .build());

    sendMixpanelEvent(category.name(), action, null);
}
 
Example #24
Source File: RecordingSession.java    From Telecine with Apache License 2.0 5 votes vote down vote up
private void cancelOverlay() {
  hideOverlay();
  listener.onEnd();

  analytics.send(new HitBuilders.EventBuilder() //
      .setCategory(Analytics.CATEGORY_RECORDING)
      .setAction(Analytics.ACTION_OVERLAY_CANCEL)
      .build());
}
 
Example #25
Source File: GoogleAnalyticsProvider.java    From AndroidAnalytics with Apache License 2.0 5 votes vote down vote up
@Override
public void event(AnalyticsEvent analyticsEvent) {
    tracker.send(
            new HitBuilders.EventBuilder()
                    .setCategory(analyticsEvent.getCategory())
                    .setAction(analyticsEvent.getAction())
                    .setLabel(analyticsEvent.getLabel())
                    .build()
    );
}
 
Example #26
Source File: BusActivity.java    From KUAS-AP-Material with MIT License 5 votes vote down vote up
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
	mDate = year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
	mTracker.send(new HitBuilders.EventBuilder().setCategory("date set").setAction("click")
			.setLabel(mDate).build());
	mTextView.setText(getString(R.string.bus_pick_date, mDate));
	getData();
}
 
Example #27
Source File: BusActivity.java    From KUAS-AP-Material with MIT License 5 votes vote down vote up
private void cancelBookBus(final List<BusModel> modelList, final int position) {
	Log.d(Constant.TAG, modelList.get(position).cancelKey);
	Helper.cancelBookingBus(BusActivity.this, modelList.get(position).cancelKey,
			new GeneralCallback() {

				@Override
				public void onSuccess() {
					super.onSuccess();
					mTracker.send(new HitBuilders.EventBuilder().setCategory("cancel bus")
							.setAction("status").setLabel("success " + mIndex).build());
					if (Memory.getBoolean(BusActivity.this, Constant.PREF_BUS_NOTIFY, false)) {
						// must cancel alarm
						AlarmHelper.cancelBusAlarm(BusActivity.this,
								modelList.get(position).endStation,
								modelList.get(position).runDateTime,
								Integer.parseInt(modelList.get(position).cancelKey));
					}
					getData();
					Toast.makeText(BusActivity.this, R.string.bus_cancel_reserve_success,
							Toast.LENGTH_LONG).show();
				}

				@Override
				public void onFail(String errorMessage) {
					super.onFail(errorMessage);
					mTracker.send(new HitBuilders.EventBuilder().setCategory("cancel bus")
							.setAction("status").setLabel("fail " + mIndex).build());
					Toast.makeText(BusActivity.this, errorMessage, Toast.LENGTH_LONG).show();
				}

				@Override
				public void onTokenExpired() {
					super.onTokenExpired();
					Utils.showTokenExpired(BusActivity.this);
					mTracker.send(new HitBuilders.EventBuilder().setCategory("token")
							.setAction("expired").build());
				}
			});
}
 
Example #28
Source File: MainActivity.java    From miracast-widget with Apache License 2.0 5 votes vote down vote up
private void sendEvent(String category, String action, String label) {
    mTracker.send(new HitBuilders.EventBuilder()
                   .setCategory(category)
                   .setAction(action)
                   .setLabel(label)
                   .build());
}
 
Example #29
Source File: BusActivity.java    From KUAS-AP-Material with MIT License 5 votes vote down vote up
@Override
public void onRefresh() {
	if (mDate == null || mDate.length() == 0) {
		return;
	}
	mTracker.send(
			new HitBuilders.EventBuilder().setCategory("refresh").setAction("swipe").build());
	mSwipeRefreshLayout.setRefreshing(true);
	isRetry = false;
	getData();
}
 
Example #30
Source File: SilentActivity.java    From KUAS-AP-Material with MIT License 5 votes vote down vote up
@Override
public void onBackPressed() {
	if (drawer != null && navigationView != null && drawer.isDrawerOpen(navigationView)) {
		drawer.closeDrawers();
	} else {
		if (mLayoutID == R.layout.activity_logout) {
			if (mTracker != null) {
				mTracker.send(new HitBuilders.EventBuilder().setCategory("logout dialog")
						.setAction("create").build());
			}
			new AlertDialog.Builder(this).setTitle(R.string.app_name)
					.setMessage(R.string.logout_check).setPositiveButton(R.string.determine,
					new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							if (mTracker != null) {
								mTracker.send(new HitBuilders.EventBuilder()
										.setCategory("logout dialog").setAction("click")
										.build());
							}
							clearUserData();
							Memory.setBoolean(SilentActivity.this, Constant.PREF_AUTO_LOGIN,
									false);
							finish();
						}
					}).setNegativeButton(R.string.cancel, null).show();
		} else {
			super.onBackPressed();
		}
	}
}