为Firebase Analytics的底部工作表屏幕设置自定义屏幕名称 [英] Setting custom screen name for bottom sheet screen for Firebase Analytics

查看:211
本文介绍了为Firebase Analytics的底部工作表屏幕设置自定义屏幕名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个带有滑动底页的活动.我想跟踪用户查看底页或主活动屏幕多长时间.

I have an activity with a sliding bottom sheet. I want to track how long does the user views the bottom sheet or the main activity screen.

我正在尝试使用FirebaseAnalytics#setCurrentScreen(Activity activity, String screenName, String screenClassOverride),以便在显示底页时显示.我用

指定screenName

I'm trying to use FirebaseAnalytics#setCurrentScreen(Activity activity, String screenName, String screenClassOverride) so that when the bottom sheet is shown. I specify the screenName with

FirebaseAnalytics.setCurrentScreen(activity, "bottom_sheet", null);

然后在关闭底纸时打电话给我

Then when the bottom sheet is closed I call

FirebaseAnalytics.setCurrentScreen(activity, null, null);

恢复为主要活动的名称.

to revert to the main activity's name.

但是我从FA获得日志:

However I get a log from FA:

W/FA:不能使用相同的类和名称来调用setCurrentScreen

W/FA: setCurrentScreen cannot be called with the same class and name

如果有人可以告诉我如何正确设置好屏幕名称.

If anyone can tell me how to properly set the screen name that would be great.

推荐答案

screenName是您要用来标识活动/片段/对话框的任何内容.

您应该以这种方式使用setCurrentScreen:

The screenName is whatever you want to use to identify your Activity/Fragment/Dialog...

You should use setCurrentScreen in this way:

FirebaseAnalytics.setCurrentScreen(activity, "bottom_sheet", this.getClass().getSimpleName());

FirebaseAnalytics.setCurrentScreen(activity, "bottom_sheet", MyActivity.class.getSimpleName());

请记住,Firebase Analytics自动记录您的当前活动,请查看来自Firebase官方文档的setCurrentScreen信息:

Remember that Firebase Analytics records your current Activity automatically, look at follow setCurrentScreen info from official Firebase docs:

请注意,屏幕报告会自动启用,并为您记录当前活动的类名,而无需您调用此函数.通过在Activity的onResume回调中调用此函数并指定screenClassOverride参数,可以有选择地覆盖类名.

Note that screen reporting is enabled automatically and records the class name of the current Activity for you without requiring you to call this function. The class name can optionally be overridden by calling this function in the onResume callback of your Activity and specifying the screenClassOverride parameter.

您可以找到此文档和更多文档

You can found this and more documentation here

现在,您收到该错误消息

Now, you are getting that error message

W/FA:不能使用相同的类和名称来调用setCurrentScreen

W/FA: setCurrentScreen cannot be called with the same class and name

setCurrentScreen()

在调用该方法的位置使用Log.d可以帮助您查看是否两次或多次调用同一件事.但是我想您不必为此担心(这是一个警告).在我当前的项目中已经看到了它,并且一切正常.

Using Log.d in where you are calling that method can help you to see if you are calling same thing twice or more. But I guess you don't have to worry about it (it's a warning). I have been seen it in my current project and everything is working fine.

这篇关于为Firebase Analytics的底部工作表屏幕设置自定义屏幕名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆