com.google.firebase.analytics.FirebaseAnalytics Java Examples
The following examples show how to use
com.google.firebase.analytics.FirebaseAnalytics.
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: ApiKeyObtainerActivity.java From CatVision-io-SDK-Android with BSD 3-Clause "New" or "Revised" License | 7 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_api_key_obtainer); Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar); setSupportActionBar(toolbar); try { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } catch (NullPointerException e) { e.printStackTrace(); } mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); }
Example #2
Source File: EhPreferenceActivity.java From MHViewer with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { setTheme(getThemeResId(Settings.getTheme())); super.onCreate(savedInstanceState); ((EhApplication) getApplication()).registerActivity(this); if (Analytics.isEnabled()) { FirebaseAnalytics.getInstance(this); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Settings.getApplyNavBarThemeColor()) { getWindow().setNavigationBarColor(AttrResources.getAttrColor(this, R.attr.colorPrimaryDark)); } }
Example #3
Source File: KcaApplication.java From kcanotify with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); String language, country; defaultLocale = Locale.getDefault(); SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE); String[] pref_locale = pref.getString(PREF_KCA_LANGUAGE, "").split("-"); if (pref_locale.length == 2) { if (pref_locale[0].equals("default")) { LocaleUtils.setLocale(defaultLocale); } else { language = pref_locale[0]; country = pref_locale[1]; LocaleUtils.setLocale(new Locale(language, country)); } } else { pref.edit().remove(PREF_KCA_LANGUAGE).apply(); LocaleUtils.setLocale(defaultLocale); } LocaleUtils.updateConfig(this, getBaseContext().getResources().getConfiguration()); FirebaseAnalytics.getInstance(this); }
Example #4
Source File: VideoActivity.java From evercam-android with GNU Affero General Public License v3.0 | 6 votes |
private void readShortcutCameraId() { Intent liveViewIntent = this.getIntent(); if (liveViewIntent != null && liveViewIntent.getExtras() != null) { //Calling firebase analytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); Bundle bundle = new Bundle(); bundle.putString("Evercam_Shortcut_Used", "Use shortcut from Home"); mFirebaseAnalytics.logEvent("Home_Shortcut", bundle); try { if (evercamCamera != null) { getMixpanel().sendEvent(R.string.mixpanel_event_use_shortcut, new JSONObject().put("Camera ID", evercamCamera.getCameraId())); } } catch (JSONException e) { e.printStackTrace(); } liveViewCameraId = liveViewIntent.getExtras().getString(HomeShortcut.KEY_CAMERA_ID, ""); } }
Example #5
Source File: PoemHistoryActivity.java From cannonball-android with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { Crashlytics.log("PoemHistory: clicked to delete poem with id: " + v.getTag()); Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, poem.getTheme()); FirebaseHelpers.deletePoem((String) v.getTag()).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { Toast.makeText(getApplicationContext(), "Poem deleted!", Toast.LENGTH_SHORT) .show(); final Intent i = new Intent(getApplicationContext(), PoemHistoryActivity.class); i.putExtra(ThemeChooserActivity.IS_NEW_POEM, true); startActivity(i); } else { Toast.makeText(getApplicationContext(), "Problem deleting poem", Toast.LENGTH_SHORT) .show(); } } } ); }
Example #6
Source File: CamerasActivity.java From evercam-android with GNU Affero General Public License v3.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menurefresh) { //Calling firebase analytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); Bundle bundle = new Bundle(); bundle.putString("Refresh", "Refresh Camera List"); mFirebaseAnalytics.logEvent("Menu", bundle); /* EvercamPlayApplication.sendEventAnalytics(this, R.string.category_menu, R.string.action_refresh, R.string.label_list_refresh); */ if (refresh != null) refresh.setActionView(R.layout.partial_actionbar_progress); startCameraLoadingTask(); } else { return super.onOptionsItemSelected(item); } return true; }
Example #7
Source File: ThemeChooserActivity.java From cannonball-android with Apache License 2.0 | 6 votes |
private void setUpHistory() { final ImageView history = (ImageView) findViewById(R.id.history); history.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Crashlytics.log("ThemeChooser: clicked History button"); Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "history"); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM_LIST, bundle); final Intent intent = new Intent(ThemeChooserActivity.this, PoemHistoryActivity.class); intent.putExtra(IS_NEW_POEM, false); startActivity(intent); } }); }
Example #8
Source File: FirebaseAnalyticsUtil.java From commcare-android with Apache License 2.0 | 6 votes |
private static void setUserProperties(FirebaseAnalytics analyticsInstance) { String domain = ReportingUtils.getDomain(); if (!TextUtils.isEmpty(domain)) { analyticsInstance.setUserProperty(CCAnalyticsParam.CCHQ_DOMAIN, domain); } String appId = ReportingUtils.getAppId(); if (!TextUtils.isEmpty(appId)) { analyticsInstance.setUserProperty(CCAnalyticsParam.CC_APP_ID, appId); } String serverName = ReportingUtils.getServerName(); if (!TextUtils.isEmpty(serverName)) { analyticsInstance.setUserProperty(CCAnalyticsParam.SERVER, serverName); } }
Example #9
Source File: FirebaseProvider.java From AnalyticsKit-Android with Apache License 2.0 | 6 votes |
/** * @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) { double durationSeconds = (endTime - startTime) / 1000; DecimalFormat df = new DecimalFormat("#.###"); finishedEvent.putAttribute(FirebaseAnalytics.Param.VALUE, df.format(durationSeconds)); logFirebaseAnalyticsEvent(finishedEvent); } else { throw new IllegalStateException("Attempted ending an event that was never started (or was previously ended): " + timedEvent.name()); } }
Example #10
Source File: MainActivity.java From android-instant-apps with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { // Get order details. int orderId = Integer.parseInt(mTxtbxOrderNumber.getText().toString()); double orderAmount = Double.parseDouble(mTxtbxOrderAmount.getText().toString()); String orderCurrency = mTxtbxCurrency.getText().toString(); // Create event details bundle. Bundle bundle = new Bundle(); bundle.putInt(FirebaseAnalytics.Param.TRANSACTION_ID, orderId); bundle.putDouble(FirebaseAnalytics.Param.VALUE, orderAmount); bundle.putString(FirebaseAnalytics.Param.CURRENCY, orderCurrency); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.ECOMMERCE_PURCHASE, bundle); Toast.makeText(getApplicationContext(), String.format(Locale.US, getString(com.example.android.instant.analytics.R.string.order_details_format), orderId, orderAmount, orderCurrency), Toast.LENGTH_SHORT) .show(); }
Example #11
Source File: LogbookActivity.java From homeassist with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_logbook); mProgressBar = findViewById(R.id.progressbar); mEmptyList = findViewById(R.id.list_empty); mConnError = findViewById(R.id.list_conn_error); Bundle params = new Bundle(); params.putString("name", this.getClass().getName()); FirebaseAnalytics.getInstance(this).logEvent("open_activity", params); Bundle bundle = getIntent().getExtras(); if (bundle != null) { mCurrentServer = CommonUtil.inflate(bundle.getString("server", ""), HomeAssistantServer.class); } final Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(getString(R.string.menu_logbook)); } setupRecyclerView(); refreshApi(); }
Example #12
Source File: MainActivity.java From text_converter with GNU General Public License v3.0 | 5 votes |
private void handleCracked() { FirebaseAnalytics.getInstance(this).logEvent("crack_version", new Bundle()); Premium.setCracked(this, true); if (getPackageName().equals(Premium.PRO_PACKAGE)) { Toast.makeText(this, "Licence check failed", Toast.LENGTH_LONG).show(); } }
Example #13
Source File: FlagNineFirebaseActivity.java From InjuredAndroid with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flag_nine_firebase); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (click == 0) { Snackbar.make(view, "Use the .json trick with database url", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); //Figure out how to login anonymously on click click = click + 1; } else if (click == 1) { Snackbar.make(view, "Filenames.", Snackbar.LENGTH_LONG) .setAction("Action",null).show(); click = click + 1; } else if (click == 2) { Snackbar.make(view, "Encoding.", Snackbar.LENGTH_LONG) .setAction("Action",null).show(); click = 0; } } }); }
Example #14
Source File: BrowsingAnalyticsController.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
public void logCategoryEvent(BookCategory bookCategory) { if (mFirebaseAnalytics != null) { Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, getCategoryValue(bookCategory)); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM_LIST, bundle); } }
Example #15
Source File: LbrynetMessagingService.java From lbry-android with MIT License | 5 votes |
@Override public void onMessageReceived(RemoteMessage remoteMessage) { if (firebaseAnalytics == null) { firebaseAnalytics = FirebaseAnalytics.getInstance(this); } Map<String, String> payload = remoteMessage.getData(); if (payload != null) { String type = payload.get("type"); String url = payload.get("target"); String title = payload.get("title"); String body = payload.get("body"); String name = payload.get("name"); // notification name String contentTitle = payload.get("content_title"); String channelUrl = payload.get("channel_url"); //String publishTime = payload.get("publish_time"); String publishTime = null; if (type != null && getEnabledTypes().indexOf(type) > -1 && body != null && body.trim().length() > 0) { // only log the receive event for valid notifications received if (firebaseAnalytics != null) { Bundle bundle = new Bundle(); bundle.putString("name", name); firebaseAnalytics.logEvent(LbryAnalytics.EVENT_LBRY_NOTIFICATION_RECEIVE, bundle); } sendNotification(title, body, type, url, name, contentTitle, channelUrl, publishTime); } } }
Example #16
Source File: AnalyticsImpl.java From island with Apache License 2.0 | 5 votes |
private AnalyticsImpl(final Context context) { final GoogleAnalytics google_analytics = GoogleAnalytics.getInstance(context); if (BuildConfig.DEBUG) google_analytics.setDryRun(true); mGoogleAnalytics = google_analytics.newTracker(R.xml.analytics_tracker); mGoogleAnalytics.enableAdvertisingIdCollection(true); mFirebaseAnalytics = FirebaseAnalytics.getInstance(FirebaseWrapper.init()); // TODO: De-dup the user identity between Mainland and Island. }
Example #17
Source File: ChatActivity.java From eternity with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case RC_INVITE: reporting.log(FirebaseAnalytics.Event.SHARE, BundleUtils.create(FirebaseAnalytics.Param.VALUE, resultCode)); return; default: super.onActivityResult(requestCode, resultCode, data); } }
Example #18
Source File: MyApp.java From Learning-Resources with MIT License | 5 votes |
@Override public void onCreate() { super.onCreate(); mInstance = this; Fabric.with(this, new Answers()); mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); }
Example #19
Source File: ITagApplication.java From itag with GNU General Public License v3.0 | 5 votes |
static public void faITagLost(boolean error) { Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "itag_itag_lost_error"); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Lost with error"); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "boolean"); bundle.putBoolean(FirebaseAnalytics.Param.VALUE, error); fa("itag_itag_lost"); }
Example #20
Source File: FirebaseProvider.java From AnalyticsKit-Android with Apache License 2.0 | 5 votes |
/** * Initializes a new {@code FirebaseProvider} object. * * @param firebaseAnalytics the initialized {@code FirebaseAnalytics} instance associated with the application */ public FirebaseProvider(@NonNull FirebaseAnalytics firebaseAnalytics) { this(firebaseAnalytics, new PriorityFilter() { @Override public boolean shouldLog(int priorityLevel) { return true; // Log all events, regardless of priority } }); }
Example #21
Source File: MainActivity.java From Instagram-Profile-Downloader with MIT License | 5 votes |
public void addToFirebase() { // Obtain the Firebase Analytics instance. firebaseAnalytics = FirebaseAnalytics.getInstance(this); User user = new User(); user.setDevice_id(FirebaseInstanceId.getInstance().getToken()); user.setFull_name(PreferencesManager.getPref(GlobalConstant.FULL_NAME)); user.setUser_id(PreferencesManager.getPref(GlobalConstant.USER_ID)); user.setUsername(PreferencesManager.getPref(GlobalConstant.USERNAME)); user.setDevice_name(android.os.Build.MODEL); Bundle bundle = new Bundle(); bundle.putString(GlobalConstant.FULL_NAME, user.getFull_name()); bundle.putString(GlobalConstant.USER_ID, user.getUser_id()); bundle.putString(GlobalConstant.USERNAME, user.getUsername()); bundle.putString(GlobalConstant.DEVICE_TYPE, user.getDevice_name()); bundle.putString(GlobalConstant.DEVICE_ID, user.getDevice_id()); //Logs an app event. firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle); //Sets whether analytics collection is enabled for this app on this device. firebaseAnalytics.setAnalyticsCollectionEnabled(true); //Sets the minimum engagement time required before starting a session. The default value is 10000 (10 seconds). Let's make it 20 seconds just for the fun firebaseAnalytics.setMinimumSessionDuration(20000); //Sets the duration of inactivity that terminates the current session. The default value is 1800000 (30 minutes). firebaseAnalytics.setSessionTimeoutDuration(500); //Sets the user ID property. firebaseAnalytics.setUserId(String.valueOf(user.getUser_id())); //Sets a user property to a given value. firebaseAnalytics.setUserProperty(GlobalConstant.USER_ID, user.getUser_id()); }
Example #22
Source File: SplashActivity.java From MangoBloggerAndroidApp with Mozilla Public License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAnalytics = FirebaseAnalytics.getInstance(this); Intent i = new Intent(SplashActivity.this, WelcomeActivity.class); startActivity(i); finish(); }
Example #23
Source File: MainActivity.java From snippets-android with Apache License 2.0 | 5 votes |
public void executeGiftPolicy() { FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance(); String giftPolicy = config.getString("gift_policy"); boolean willChurn = config.getBoolean("will_churn"); if (giftPolicy.equals("gift_achievement")) { grantGiftOnLevel2(); } else if (giftPolicy.equals("gift_likelychurn") && willChurn) { grantGiftNow(); } FirebaseAnalytics.getInstance(this).logEvent("gift_policy_set", new Bundle()); }
Example #24
Source File: ITagApplication.java From itag with GNU General Public License v3.0 | 5 votes |
static public void fa(@NonNull final String event, Bundle bundle) { if (context == null) return; if (sFirebaseAnalytics == null) { sFirebaseAnalytics = FirebaseAnalytics.getInstance(context); } sFirebaseAnalytics.logEvent(event, bundle); if (BuildConfig.DEBUG) { Log.d(LT, "FA log " + event); } }
Example #25
Source File: FabricPrivacy.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
public void logCustom(Bundle event) { try { if (fabricEnabled()) { MainApp.getFirebaseAnalytics().logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, event); } else { if (L.isEnabled(L.CORE)) log.debug("Ignoring recently opted-out event: " + event.toString()); } } catch (NullPointerException | IllegalStateException e) { if (L.isEnabled(L.CORE)) log.debug("Ignoring opted-out non-initialized event: " + event.toString()); } }
Example #26
Source File: MyApp.java From Learning-Resources with MIT License | 5 votes |
public static void logShareEvent(SharePlatform platform) { Bundle bundle = new Bundle(); bundle.putInt(FirebaseAnalytics.Param.ITEM_ID, 3); bundle.putString(FirebaseAnalytics.Param.DESTINATION, platform.getPlatform()); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SHARE, bundle); Answers.getInstance().logCustom(new CustomEvent("SHARE") .putCustomAttribute("DESTINATION", platform.getPlatform()) ); Answers.getInstance().logContentView(new ContentViewEvent() .putContentName("SHARE") .putContentType(platform.getPlatform()) .putContentId("3")); }
Example #27
Source File: MainActivity.java From snippets-android with Apache License 2.0 | 5 votes |
public String getPromotedBundle() { FirebaseAnalytics.getInstance(this).logEvent("promotion_set", new Bundle()); FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance(); String promotedBundle = config.getString("promoted_bundle"); boolean will_spend = config.getBoolean("predicted_will_spend"); if (promotedBundle.equals("predicted") && will_spend) { return "premium"; } else { return promotedBundle; } }
Example #28
Source File: VideoActivity.java From evercam-android with GNU Affero General Public License v3.0 | 5 votes |
private void onVideoLoaded() { Log.d(TAG, "onVideoLoaded()"); runOnUiThread(new Runnable() { public void run() { //View gets played, show time count, and start buffering showProgressView(false); showVideoView(true); showImageView(false); startTimeCounter(); //Calling firebase analytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(VideoActivity.this); Bundle bundle = new Bundle(); bundle.putString("RTSP_Stream_Played", "Successfully played RTSP stream"); mFirebaseAnalytics.logEvent("RTSP_Streaming", bundle); StreamFeedbackItem successItem = new StreamFeedbackItem(VideoActivity .this, AppData.defaultUser.getUsername(), true); successItem.setCameraId(evercamCamera.getCameraId()); successItem.setUrl(evercamCamera.getHlsUrl()); successItem.setType(StreamFeedbackItem.TYPE_HLS); if (startTime != null) { float timeDifferenceFloat = Commons.calculateTimeDifferenceFrom (startTime); Log.d(TAG, "Time difference: " + timeDifferenceFloat + " seconds"); successItem.setLoadTime(timeDifferenceFloat); startTime = null; } } }); }
Example #29
Source File: PoemBuilderActivity.java From cannonball-android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_poem_builder); poemTheme = (Theme) getIntent().getSerializableExtra(KEY_THEME); mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); setUpViews(); }
Example #30
Source File: KcaUtils.java From kcanotify with GNU General Public License v3.0 | 5 votes |
public static void sendUserAnalytics(Context context, String event, JsonObject value) { Bundle params = new Bundle(); FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context); if (value != null) { for (String key: value.keySet()) { params.putString(key, value.get(key).getAsString()); } } mFirebaseAnalytics.logEvent(event, params); }