Quickstart-android: setCurrentScreen in onResume sends screen_view twice

Created on 9 Jan 2019  路  5Comments  路  Source: firebase/quickstart-android

We are trying to set a custom name or class name to the screen of the screen_view event but the event is sent twice even if we do it inside onResume of the activity.

https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#setCurrentScreen(android.app.Activity,%20java.lang.String,%20java.lang.String)

analytics

Most helpful comment

Still facing this issue, is there a fix for this yet?

All 5 comments

@llooz can you provide some code that reproduces the problem? Is this in an Activity or a Fragment? And does it send twice automatically or do you have to resume the app?

I'm experiencing the same issue. I call setCurrentScreen in the onResume of an activity and I see in the debug view in my firebase console 2 events: one with the default name and one with the custom name I passed to setCurrentScreen.
This is the exact same behaviour reported for the iOS sdk here: https://github.com/firebase/firebase-ios-sdk/issues/1894

Do you have any insight on how to avoid this? Tracking screen views at the moment is pretty unusable because I can't rely on the numbers I see, due to those duplications.

Same issue here. It's really not hard to repro at all. Just put a call to setScreenName() in any activity's onResume() and no-where else and you get double events.

Definitely disappointing to expect it to work properly. It only dupes when creating the Activity. IOS bug hasn't moved in almost an entire year so not expecting much any traction at all. It's fixable, but I can see why y'all would punt.

You could probably use WeakReference if setScreenName is called in Activity.onCreate() and if Activity isn't known, hold the reference and resolve it when the onResume() gets called that generates the bad event. This would also help you avoid the other behavior where calling setScreenName in onCreate() doesn't fire anything if the Activity isn't known yet. Then the SDK would work forgivingly without the extra event noise. You also wouldn't have to worry about knowing whether an explicit call to setScreenName is coming, you could just assume if someone tries to set early, resolve it when you get the actual lifecycle event. No need to try to translate intent.

Still facing this issue, is there a fix for this yet?

Still encountering the same problem.

In fact, a lot of trouble reporting events and parameters using firebase...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

charlizesmith picture charlizesmith  路  5Comments

the-dagger picture the-dagger  路  4Comments

rahuldevanavar91 picture rahuldevanavar91  路  5Comments

aselims picture aselims  路  6Comments

tekinarslan picture tekinarslan  路  5Comments