Does Firebase Analytics need to be started on all activities?

2

I'm at an awkward stalemate. I'm creating the custom of using Firebase in my project, but I do not understand how to use it. Do I need to put the Firebase Analytics code in all activities or just one?

    
asked by anonymous 02.12.2016 / 01:38

1 answer

1

According to the Firebase Android SDK Version 9.8 - October 24, 2016 < strong> Automatic Screen Tracking is already supported by Firebase Analytics on Android, while since a while. For more details, you can follow the guidelines in Firebase Analytics documentation .

However, another alternative to not having to start in all Activities would be to create a global variable in a class that extends the class Application :

public class MyLittleApplication extends Application {
    public static  FirebaseAnalytics fbAnalytics;
    @Override
        public void onCreate() {
        super.onCreate();
        fbAnalytics= FirebaseAnalytics.getInstance(this);
    }
}

No manifest.xml you use the <application > tag like this:

<application
  android:name=".MyLittleApplication" ...
    
24.12.2016 / 14:05