Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flurry analytics in every Activity?

I want to integrate flurry analytics in my android application, it looks really simple. But i am not familiar with flurry and how it works.

Should i add the code :

public void onStart()
{
super.onStart();
FlurryAgent.onStartSession(sample, “APIXXXXXXXXXXXX”);

}

in every activity?

My application uses a lot of activities and i don't really care for tracking which of the activities is used, only the number of installations, sessions and session length. But is the session length available if the flurry code is only added in the startup activity?

I know most of the information i want is available in play store already, but i want to try this to have an overview of applications on different platforms.

like image 884
Jasper Avatar asked Sep 06 '12 19:09

Jasper


1 Answers

Here is a great answer : https://stackoverflow.com/a/8062568/1635817

I suggest you to create a "BaseActivity" and to tell all your activities to extend it so you don't have to copy/paste those lines in every activity class.

Something like this :

public class BaseActivity extends Activity
{
    public void onStart()
    {
       super.onStart();
       FlurryAgent.onStartSession(this, "YOUR_KEY");
       // your code
    }

    public void onStop()
    {
       super.onStop();
       FlurryAgent.onEndSession(this);
       // your code
    }
}

In response to @conor comment :

From Flurry's documentation

So long as there is any Context that has called onStartSession(Context, String) but not onEndSession(Context), the session will be continued. Also, if a new Context calls onStartSession(Context, String) within 10 seconds (the default session timeout length) of the last Context calling onEndSession, then the session will be resumed, instead of a new session being created. Session length, usage frequency, events and errors will continue to be tracked as part of the same session. This ensures that as a user transitions from one Activity to another in your application they will not have a separate session tracked for each Activity, but will have a single session that spans many activities.

like image 53
florianmski Avatar answered Oct 04 '22 17:10

florianmski