本文整理汇总了Java中com.google.android.gms.analytics.HitBuilders类的典型用法代码示例。如果您正苦于以下问题:Java HitBuilders类的具体用法?Java HitBuilders怎么用?Java HitBuilders使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HitBuilders类属于com.google.android.gms.analytics包,在下文中一共展示了HitBuilders类的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: sendSupportMail
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
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());
}
}
示例3: shareVK
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
private void shareVK() {
if (VKSdk.isLoggedIn() || VKSdk.wakeUpSession()) {
new VKShareDialog()
.setText(getString(R.string.like_text))
.setAttachmentLink(getString(R.string.like_url_title), getString(R.string.like_url))
.setShareDialogListener(new VKShareDialog.VKShareDialogListener() {
@Override
public void onVkShareComplete(int i) {
showThankYouToast();
((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
.send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("VK").setLabel("OK").build());
}
@Override
public void onVkShareCancel() {
((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
.send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("VK").setLabel("Cancel").build());
}
})
.show(getFragmentManager(), "SHARE");
} else
VKSdk.authorize(NavigationActivity.vkScope, true, false);
}
示例4: shareTwitter
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void shareTwitter() {
Intent twitterIntent = new Intent();
twitterIntent.setType("text/plain");
twitterIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.like_text));
final PackageManager packageManager = getActivity().getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(twitterIntent, PackageManager.MATCH_DEFAULT_ONLY);
boolean found = false;
for (ResolveInfo resolveInfo : list) {
String p = resolveInfo.activityInfo.packageName;
if (p != null && p.startsWith("com.twitter.android")) {
found = true;
twitterIntent.setPackage(p);
startActivity(twitterIntent);
((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
.send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("Twitter").setLabel("App").build());
}
}
if (!found) {
ProgressDialog progressDialog = new ProgressDialog(getActivity());
TwitterShare d = new TwitterShare(
getActivity(), progressDialog,
"http://twitter.com/share?text=" + Uri.encode(getString(R.string.like_text_twitter)) + "&url=" + Uri.parse(getString(R.string.like_url)));
d.show();
progressDialog.setMessage(getString(R.string.text_loading));
progressDialog.setCancelable(true);
progressDialog.show();
((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
.send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("Twitter").setLabel("Web").build());
}
}
示例5: onViewCreated
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
listView = (RecyclerView)view.findViewById(android.R.id.list);
listView.setLayoutManager(new LinearLayoutManager(getActivity()));
listView.setItemAnimator(new DefaultItemAnimator());
listView.setAdapter(adapter);
view.findViewById(R.id.fabNewPlaylist).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
newPlaylist();
}
});
Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER);
t.setScreenName("List of playlists");
t.send(new HitBuilders.AppViewBuilder().build());
}
示例6: setTheme
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
private void setTheme() {
int themeIndex = PreferenceManager.getDefaultSharedPreferences(this).getInt(getString(R.string.key_theme), 0);
int theme = R.style.Theme_IdealMedia_Colored;
switch (themeIndex) {
case 0:
theme = R.style.Theme_IdealMedia_Colored;
break;
case 1:
theme = R.style.Theme_IdealMedia_Colored_Dark;
break;
case 2:
theme = R.style.Theme_IdealMedia_Dark;
break;
}
setTheme(theme);
getTracker(NavigationActivity.TrackerName.APP_TRACKER)
.send(new HitBuilders.EventBuilder().setCategory("UX").setAction("theme").setLabel("index " + themeIndex).build());
}
示例7: 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);
}
}
示例8: onResume
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
// if (getApplication().getAppFirmata().isOpen() == false && !getApplication().getIsDemoMode()) return;
if (getApplication().getRunningShields().get(getControllerTag()) == null) {
if (!reInitController())
return;
}
if (activity == null || activity.findViewById(R.id.shieldStatus) == null)
return;
MainActivity.currentShieldTag = getControllerTag();
// restore the staus of shield interaction toggle button
if (getApplication().getRunningShields().get(getControllerTag()) != null)
((ToggleButton) activity.findViewById(R.id.shieldStatus))
.setChecked(getApplication().getRunningShields().get(
getControllerTag()).isInteractive);
// Google analytics tracking
getApplication().getTracker().setScreenName(getControllerTag());
getApplication().getTracker().send(
new HitBuilders.ScreenViewBuilder().build());
// Logging current view for crashlytics
CrashlyticsUtils.setString("Current View", getTag());
((T) this).doOnResume();
}
示例9: shouldOverrideUrlLoading
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// if URL's host is ficsave.xyz, open in webview, else let android open it somewhere else
if (Uri.parse(url).getHost().equals(mActivity.getString(R.string.ficsave_host))) {
return false;
}
mGTracker.send(new HitBuilders.EventBuilder()
.setCategory("WebViewClientCategory")
.setAction("Other Url than ficsave Opened")
.setLabel(URL_LABEL + url)
.setValue(1)
.build());
Bundle bundle = new Bundle();
bundle.putString("Url", url);
mFTracker.logEvent("OtherUrlthanficsaveOpened", bundle);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
mActivity.startActivity(intent);
return true;
}
示例10: getIntentViewUrl
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
private String getIntentViewUrl() {
String url = "";
Intent intent = getIntent();
String intentAction = intent.getAction();
if (Intent.ACTION_VIEW.equals(intentAction)) {
url = intent.getData().toString();
Log.d("ficsaveM/deepLink", url + " " + intent.toString());
mGTracker.send(new HitBuilders.EventBuilder()
.setCategory(MAIN_PAGE_CATEGORY)
.setAction("Deep Link Accessed")
.setLabel(URL_LABEL + url)
.setValue(1)
.build());
Bundle bundle = new Bundle();
bundle.putString("Url", url);
mFTracker.logEvent("DeepLinkAccessed", bundle);
}
return url;
}
示例11: setIntentFicUrl
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
private void setIntentFicUrl() {
ficUrl = "";
Intent intent = getIntent();
if (intent != null) {
String intentType = intent.getType();
String intentAction = intent.getAction();
Log.d("ficsaveM/intentReceived", intentAction + " " + intent.toString());
if (Intent.ACTION_SEND.equals(intentAction) && intentType != null && "text/plain".equals(intentType)) {
Matcher m = Patterns.WEB_URL.matcher(intent.getStringExtra(Intent.EXTRA_TEXT));
while (m.find()) {
String url = m.group();
ficUrl = url;
Log.d("ficsaveM/setIntFicUrl", "URL extracted: " + url);
mGTracker.send(new HitBuilders.EventBuilder()
.setCategory(MAIN_PAGE_CATEGORY)
.setAction("Fic Url Set")
.setLabel(URL_LABEL + ficUrl)
.setValue(1)
.build());
Bundle bundle = new Bundle();
bundle.putString("Url", ficUrl);
mFTracker.logEvent("FicUrlSet", bundle);
}
}
}
}
示例12: init
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
public void init(BaseActivity activity){
baseActivity = activity;
activityStack.push(activity);
sh = new SharedHelper(activity.getApplicationContext());
loadingDialog = new LoadingDialog(activity);
loadingDialog.setOnCancelListener((dialogInterface -> canceled = true));
String screenName = activity.getClass().getSimpleName();
activityMap.put(screenName + System.currentTimeMillis(), activity);
if (SStaticR.ANALYTICS_ON){
// Obtain the shared Tracker instance.
LIVE application = (LIVE)baseActivity.getApplication();
Tracker mTracker = application.getDefaultTracker();
mTracker.setScreenName(screenName);
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
}
示例13: endTimedEvent
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
/**
* @see AnalyticsKitProvider
*/
@Override
public void endTimedEvent(@NonNull AnalyticsEvent timedEvent) throws IllegalStateException
{
ensureTimeTrackingMaps();
long endTime = System.currentTimeMillis();
Long startTime = this.eventTimes.remove(timedEvent.name());
AnalyticsEvent finishedEvent = this.timedEvents.remove(timedEvent.name());
if (startTime != null && finishedEvent != null)
{
HitBuilders.TimingBuilder timingBuilder = new HitBuilders.TimingBuilder();
timingBuilder.setLabel(finishedEvent.name())
.setCategory("Timed Events")
.setValue(endTime - startTime);
// add any custom attributes already set on the event
timingBuilder.setAll(stringifyAttributesMap(finishedEvent.getAttributes()));
this.tracker.send(timingBuilder.build());
}
else
{
throw new IllegalStateException("Attempted ending an event that was never started (or was previously ended): " + timedEvent.name());
}
}
示例14: addDimensions
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
private <T> T addDimensions(T builder, HashMap<String, Object> params) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
try {
int dimensionInteger = Integer.parseInt(entry.getKey());
if (entry.getValue() instanceof String) {
if (builder instanceof HitBuilders.EventBuilder) {
((HitBuilders.EventBuilder) builder).setCustomDimension(dimensionInteger, (String) entry.getValue());
} else if (builder instanceof HitBuilders.TimingBuilder) {
((HitBuilders.TimingBuilder) builder).setCustomDimension(dimensionInteger, (String) entry.getValue());
} else if (builder instanceof HitBuilders.ScreenViewBuilder) {
((HitBuilders.ScreenViewBuilder) builder).setCustomDimension(dimensionInteger, (String) entry.getValue());
}
}
} catch (NumberFormatException ignore) {
}
}
return builder;
}
示例15: addMetrics
import com.google.android.gms.analytics.HitBuilders; //导入依赖的package包/类
private <T> T addMetrics(T builder, HashMap<String, Object> params) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
try {
int metricInteger = Integer.parseInt(entry.getKey());
if (entry.getValue() instanceof Float) {
if (builder instanceof HitBuilders.EventBuilder) {
((HitBuilders.EventBuilder) builder).setCustomMetric(metricInteger, (Float) entry.getValue());
} else if (builder instanceof HitBuilders.TimingBuilder) {
((HitBuilders.TimingBuilder) builder).setCustomMetric(metricInteger, (Float) entry.getValue());
} else if (builder instanceof HitBuilders.ScreenViewBuilder) {
((HitBuilders.ScreenViewBuilder) builder).setCustomMetric(metricInteger, (Float) entry.getValue());
}
}
} catch (NumberFormatException ignore) {
}
}
return builder;
}