com.google.android.gms.analytics.Tracker Java Examples
The following examples show how to use
com.google.android.gms.analytics.Tracker.
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: SettingsActivity.java From android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } if (getIntent().getBooleanExtra(EXTRA_FROM_NOTIFICATION, false)) { if (accountManager.allowAnalytics(this)) { FiveCallsApplication application = (FiveCallsApplication) getApplication(); Tracker tracker = application.getDefaultTracker(); tracker.send(new HitBuilders.EventBuilder() .setCategory("Reminders") .setAction("SettingsFromReminder") .setValue(1) .build()); } } getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()) .commit(); }
Example #2
Source File: ConfigurationActivity.java From Noyze with Apache License 2.0 | 6 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(this); MainThreadBus.get().register(this); ChangeLogDialog.show(this, true); // TRACK: activity view. if (NoyzeApp.GOOGLE_ANALYTICS) { Tracker t = ((NoyzeApp) getApplication()).getTracker( NoyzeApp.TrackerName.APP_TRACKER); t.setScreenName(getClass().getSimpleName()); t.send(new HitBuilders.AppViewBuilder().build()); } }
Example #3
Source File: ConfigurationActivity.java From Noyze with Apache License 2.0 | 6 votes |
@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: SettingsActivity.java From android with MIT License | 6 votes |
public static void updateNotificationsPreference(FiveCallsApplication application, AccountManager accountManager, String result) { accountManager.setNotificationPreference(application, result); if (TextUtils.equals("0", result)) { OneSignalNotificationController.enableTopNotifications(); } else if (TextUtils.equals("1", result)) { OneSignalNotificationController.enableAllNotifications(); } else if (TextUtils.equals("2", result)) { OneSignalNotificationController.disableNotifications(); } // If the user changes the settings there's no need to show the dialog in the future. accountManager.setNotificationDialogShown(application, true); // Log this to Analytics if (accountManager.allowAnalytics(application)) { Tracker tracker = application.getDefaultTracker(); tracker.send(new HitBuilders.EventBuilder() .setCategory("Notifications") .setAction("NotificationSettingsChange") .setLabel(application.getApplicationContext().getResources() .getStringArray(R.array.notification_options)[Integer.valueOf(result)]) .setValue(1) .build()); } }
Example #5
Source File: GAlette.java From GAlette with Apache License 2.0 | 6 votes |
private void sendAppView0(Object target, Context appContext, Method method, Object[] arguments) { final SendAppView analyticsAnnotation = method.getAnnotation(SendAppView.class); final Tracker tracker = trackerFrom(appContext, analyticsAnnotation.trackerName()); if (tracker == null) { return; } final HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder(); try { final FieldBuilder<String> screenNameBuilder = createStringFieldBuilder(analyticsAnnotation.screenNameBuilder()); final String screenName = screenNameBuilder.build(Fields.SCREEN_NAME, analyticsAnnotation.screenName(), target, method, arguments); tracker.setScreenName(screenName); HitInterceptor hitInterceptor = hitInterceptorFrom(appContext, analyticsAnnotation.trackerName()); hitInterceptor.onScreenView(new ScreenViewBuilderDelegate(builder)); } finally { tracker.send(builder.build()); } }
Example #6
Source File: BarometerNetworkActivity.java From PressureNet with GNU General Public License v3.0 | 6 votes |
@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 #7
Source File: PlaylistsFragment.java From IdealMedia with Apache License 2.0 | 6 votes |
@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()); }
Example #8
Source File: OneSignalNotificationController.java From android with MIT License | 6 votes |
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 #9
Source File: SearchList.java From moviedb-android with Apache License 2.0 | 6 votes |
/** * 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. */ @SuppressLint("ShowToast") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View rootView = inflater.inflate(R.layout.searchlist, container, false); listView = (AbsListView) rootView.findViewById(R.id.movieslist); listView.setOnItemClickListener(this); toastLoadingMore = Toast.makeText(getActivity(), R.string.loadingMore, Toast.LENGTH_SHORT); activity = ((MainActivity) getActivity()); Tracker t = ((MovieDB) activity.getApplication()).getTracker(); t.setScreenName("Search"); t.send(new HitBuilders.ScreenViewBuilder().build()); return rootView; }
Example #10
Source File: PanelShortcutActivity.java From Noyze with Apache License 2.0 | 5 votes |
public void onHandleIntent(Intent intent) { if (null == intent) return; LOGD(TAG, "onHandleIntent(" + intent.toString() + ")"); String action = intent.getAction(); // TRACK: activity view. if (NoyzeApp.GOOGLE_ANALYTICS) { Tracker t = ((NoyzeApp) getApplication()).getTracker( NoyzeApp.TrackerName.APP_TRACKER); t.setScreenName(getClass().getSimpleName()); t.send(new HitBuilders.AppViewBuilder().build()); } // We've got one mission and one mission only! if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { setupShortcut(); return; } // If Noyze is active, open the panel. if (VolumeAccessibilityService.isEnabled(this)) { Intent openPanel = new Intent(getApplicationContext(), VolumeAccessibilityService.class); openPanel.putExtra("show", true); openPanel.setPackage(getPackageName()); startService(openPanel); } else { // If it's not, bring up the app. Intent openApp = getPackageManager().getLaunchIntentForPackage(getPackageName()); openApp.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(openApp); } finish(); }
Example #11
Source File: ListMovieWatchedFragment.java From Movie-Check with Apache License 2.0 | 5 votes |
@Override public void onResume() { super.onResume(); Tracker defaultTracker = ((MovieCheckApplication) getActivity().getApplication()).getDefaultTracker(); defaultTracker.setScreenName("List Movie Watched by the User Screen"); defaultTracker.send(new HitBuilders.ScreenViewBuilder().build()); }
Example #12
Source File: BaseApplication.java From example with Apache License 2.0 | 5 votes |
/** * Gets the default {@link Tracker} for this {@link Application}. * * @return tracker */ synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker(R.xml.global_tracker); } return mTracker; }
Example #13
Source File: ClimbTrackerApplication.java From climb-tracker with Apache License 2.0 | 5 votes |
synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(R.xml.global_tracker); } return mTracker; }
Example #14
Source File: EditLocationActivity.java From PressureNet with GNU General Public License v3.0 | 5 votes |
@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 #15
Source File: NoyzeApp.java From Noyze with Apache License 2.0 | 5 votes |
synchronized Tracker getTracker(TrackerName trackerId) { if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker("UA-41252760-2") : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker) : analytics.newTracker(R.xml.global_tracker); t.enableAdvertisingIdCollection(false); t.setAnonymizeIp(true); t.setUseSecure(true); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); }
Example #16
Source File: ListNowPlayingMoviesActivity.java From Movie-Check with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); Tracker defaultTracker = ((MovieCheckApplication) getApplication()).getDefaultTracker(); defaultTracker.setScreenName("List Of Now Playing Movies Screen"); defaultTracker.send(new HitBuilders.ScreenViewBuilder().build()); }
Example #17
Source File: HomeActivity.java From Movie-Check with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); Tracker defaultTracker = ((MovieCheckApplication) getApplication()).getDefaultTracker(); defaultTracker.setScreenName("Home Screen"); defaultTracker.send(new HitBuilders.ScreenViewBuilder().build()); }
Example #18
Source File: ListMoviesByGenreActivity.java From Movie-Check with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); Tracker defaultTracker = ((MovieCheckApplication) getApplication()).getDefaultTracker(); defaultTracker.setScreenName("List Movies By Genre Screen"); defaultTracker.send(new HitBuilders.ScreenViewBuilder().build()); }
Example #19
Source File: UserProfileActivity.java From Movie-Check with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); Tracker defaultTracker = ((MovieCheckApplication) getApplication()).getDefaultTracker(); defaultTracker.setScreenName("User Profile Screen"); defaultTracker.send(new HitBuilders.ScreenViewBuilder().build()); }
Example #20
Source File: PanelShortcutActivity.java From Noyze with Apache License 2.0 | 5 votes |
public void onHandleIntent(Intent intent) { if (null == intent) return; LOGD(TAG, "onHandleIntent(" + intent.toString() + ")"); String action = intent.getAction(); // TRACK: activity view. if (NoyzeApp.GOOGLE_ANALYTICS) { Tracker t = ((NoyzeApp) getApplication()).getTracker( NoyzeApp.TrackerName.APP_TRACKER); t.setScreenName(getClass().getSimpleName()); t.send(new HitBuilders.AppViewBuilder().build()); } // We've got one mission and one mission only! if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { setupShortcut(); return; } // If Noyze is active, open the panel. if (VolumeAccessibilityService.isEnabled(this)) { Intent openPanel = new Intent(getApplicationContext(), VolumeAccessibilityService.class); openPanel.putExtra("show", true); openPanel.setPackage(getPackageName()); startService(openPanel); } else { // If it's not, bring up the app. Intent openApp = getPackageManager().getLaunchIntentForPackage(getPackageName()); openApp.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(openApp); } finish(); }
Example #21
Source File: AppModule.java From droidkaigi2016 with Apache License 2.0 | 5 votes |
@Singleton @Provides public Tracker provideGoogleAnalyticsTracker(Context context) { GoogleAnalytics ga = GoogleAnalytics.getInstance(context); Tracker tracker = ga.newTracker(BuildConfig.GA_TRACKING_ID); tracker.enableAdvertisingIdCollection(true); tracker.enableExceptionReporting(true); return tracker; }
Example #22
Source File: BaseApplication.java From io16experiment-master with Apache License 2.0 | 5 votes |
/** * Gets the default {@link Tracker} for this {@link Application}. * * @return tracker */ synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setLocalDispatchPeriod(60); analytics.setDryRun(BuildConfig.DEBUG); mTracker = analytics.newTracker(R.xml.app_tracker); mTracker.enableAdvertisingIdCollection(true); mTracker.enableAutoActivityTracking(true); mTracker.enableExceptionReporting(true); } return mTracker; }
Example #23
Source File: MiracastApplication.java From miracast-widget with Apache License 2.0 | 5 votes |
/** * Gets the default {@link Tracker} for this {@link Application}. * @return tracker */ synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker(R.xml.global_tracker); } return mTracker; }
Example #24
Source File: AnalyticsUnitTest.java From openshop.io-android with MIT License | 5 votes |
@Test public void prepareTrackersAndFbLoggerTest() throws Exception { prepareMockedFields(); // Tested method invocation Analytics.prepareTrackersAndFbLogger(testShop, mockContext); // Verify results verifyStatic(times(1)); GoogleAnalytics.getInstance(mockContext); verifyStatic(never()); Analytics.deleteAppTrackers(); verify(mockAnalytics, times(1)).newTracker(testShop.getGoogleUa()); verify(mockAnalytics, times(1)).newTracker(R.xml.global_tracker); verify(mockTrackerApp, times(1)).enableAutoActivityTracking(true); verify(mockTrackerApp, times(1)).enableExceptionReporting(false); verify(mockTrackerApp, times(1)).enableAdvertisingIdCollection(true); verifyNoMoreInteractions(mockTrackerApp); verify(mockTracker, times(1)).enableAutoActivityTracking(true); verify(mockTracker, times(1)).enableExceptionReporting(true); verify(mockTracker, times(1)).enableAdvertisingIdCollection(true); verifyNoMoreInteractions(mockTracker); HashMap<String, Tracker> trackersField = Whitebox.getInternalState(Analytics.class, "mTrackers"); assertEquals(trackersField.size(), 2); AppEventsLogger appEventsLoggerField = Whitebox.getInternalState(Analytics.class, "facebookLogger"); assertNotEquals(appEventsLoggerField, null); }
Example #25
Source File: Analytics.java From openshop.io-android with MIT License | 5 votes |
/** * Prepare Google analytics trackers and Facebook events logger. * Send UTM campaign if exist. * * @param shop shop with app specific Google Ua or null, if global tracker is enough. * @param context application context. */ public static synchronized void prepareTrackersAndFbLogger(Shop shop, Context context) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG if (shop == null) { deleteAppTrackers(); } else { if (!mTrackers.containsKey(TRACKER_APP) && analytics != null) { if (shop.getGoogleUa() != null && !shop.getGoogleUa().isEmpty()) { Timber.d("Set new app tracker with id: %s", shop.getGoogleUa()); // App tracker determined by shop Tracker appTracker = analytics.newTracker(shop.getGoogleUa()); appTracker.enableAutoActivityTracking(true); appTracker.enableExceptionReporting(false); appTracker.enableAdvertisingIdCollection(true); mTrackers.put(TRACKER_APP, appTracker); } else { Timber.e(new RuntimeException(), "Creating GA app tracker with empty Google UA"); } } else { Timber.e("Trackers for this app already exist."); } } // Add global tracker only one time. if (!mTrackers.containsKey(TRACKER_GLOBAL) && analytics != null) { Timber.d("Set new global tracker."); // Global app tracker Tracker appTrackerGlobal = analytics.newTracker(R.xml.global_tracker); appTrackerGlobal.enableAutoActivityTracking(true); appTrackerGlobal.enableExceptionReporting(true); appTrackerGlobal.enableAdvertisingIdCollection(true); mTrackers.put(TRACKER_GLOBAL, appTrackerGlobal); // Send camping info only once time. sendCampaignInfo(); } facebookLogger = AppEventsLogger.newLogger(MyApplication.getInstance()); }
Example #26
Source File: NewWelcomeActivity.java From PressureNet with GNU General Public License v3.0 | 5 votes |
@Override protected void onStart() { // Get tracker. Tracker t = ((PressureNetApplication) getApplication()) .getTracker(TrackerName.APP_TRACKER); // Set screen name. t.setScreenName("New Welcome"); // Send a screen view. t.send(new HitBuilders.ScreenViewBuilder().build()); super.onStart(); }
Example #27
Source File: MainActivity.java From Smartlab with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = analytics.newTracker("UA-43986081-2"); t.send(new HitBuilders.AppViewBuilder().build()); }
Example #28
Source File: AboutActivity.java From PressureNet with GNU General Public License v3.0 | 5 votes |
@Override protected void onStart() { // Get tracker. Tracker t = ((PressureNetApplication) getApplication()) .getTracker(TrackerName.APP_TRACKER); // Set screen name. t.setScreenName("About"); // Send a screen view. t.send(new HitBuilders.ScreenViewBuilder().build()); super.onStart(); }
Example #29
Source File: NotificationSender.java From PressureNet with GNU General Public License v3.0 | 5 votes |
synchronized Tracker getTracker(TrackerName trackerId) { if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(mContext); Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PressureNETConfiguration.GA_TOKEN) : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker) : analytics.newTracker(R.xml.global_tracker); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); }
Example #30
Source File: AnalyticsTrackers.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
public synchronized Tracker get(Target target) { if (!mTrackers.containsKey(target)) { Tracker tracker; switch (target) { case APP: tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker); break; default: throw new IllegalArgumentException("Unhandled analytics target " + target); } mTrackers.put(target, tracker); } return mTrackers.get(target); }