Hi,

I was looking at using google analytics for android. We can use the
basic template below to record "page views":


public class MyActivity extends Activity {

    private GoogleAnalyticsTracker tracker;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        tracker = GoogleAnalyticsTracker.getInstance();
        tracker.trackPageView("/test/" + getClass().getSimpleName());
     }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        tracker.dispatch();
        tracker.stop();
    }
}

I wonder if anyone else is doing this, and if it's a significant
battery drain? Ideally I wouldn't have to dispatch() on every
onDestroy(), I'd rather move the dispatch() call to be called once at
each app startup. But I'm not sure if the tracker persists all this
data for you between application runs. The docs don't say much about
it:

http://code.google.com/mobile/analytics/docs/android/

So, in other words, will this work?:


public class MyApp extends Application {
    @Override
    public void onCreate() {
        // If tracker in fact does persist all my tracks between app
sessions, then push them
        // all up only once every time the app starts?
        GoogleAnalyticsTracker tracker =
GoogleAnalyticsTracker.getInstance();
        tracker.dispatch();
    }
}


Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to