Firebase Analytics不会在信息中心中显示任何数据

时间:2016-11-16 13:36:39

标签: android firebase firebase-analytics

我正在尝试使用Firebase Analytics记录事件和当前屏幕,我在logcat中获取此日志:

App measurement is starting up, version: 9877
Registered activity lifecycle callback
Checking service availability
Service available
Connecting to remote service
onActivityCreated
Activity resumed, time: 234385086
Connected to remote service
Logging event (FE): _e, Bundle[{_o=auto, _et=9309, _sc=IntroActivity, _si=-6959962515326329023}]
setCurrentScreen cannot be called while no activity active
Logging event (FE): select_content, Bundle[{item_name=main, _o=app, content_type=image, item_id=1}]

这是我的代码:

mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "1");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "main");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
mFirebaseAnalytics.setCurrentScreen(MainActivity.this,"Main","Home");

但在转到Firebase控制台后,我的应用程序中没有数据。为什么呢?

1 个答案:

答案 0 :(得分:7)

正如方法文档所提到的那样,当活动在前台时(调用回调setCurrentScreen之前),您应该从活动onResume回调中调用onPause。屏幕名称/类仅适用于前台的当前活动。在没有活动的情况下调用它是前景是不可能的,因为没有可见的UI来关联屏幕名称/类,因此您会收到此调用无效的警告。