Search code examples
androidflurry

When to use init() with delayed activity with Flurry on Android


I just started getting interested in Flurry, and there is things Im not sure about. I have an application that start an activity when the screen is switched on (through a service), even when the application itself is not running. If I use the init() function in the Application class, as advised by Flurry's tutorial, do I still have to use it in the delayed activity, since the application is closed?


Solution

  • You should not call init() in your Activity, especially as you are already calling it in your Application class. FlurryAgent.init(Context, String) is meant to be called once per entire application life-cycle.

    What you should call in all your Activities is FlurryAgent.onStartSession(Context) to start a session. However, you do not need to call this if your application is targeting API 14+.

    In your case, the Flurry SDK will be initialized in your Application class, but a session will only start after the Activity#onStart() method of your delayed Activity (i.e. when your Activity is on-screen).

    You can read Flurry docs to see where to place these calls.