Latest Tweets

 

Improving Google Analytics performance on Android

A few months ago I discovered that the Google Analytics Java library for Android can interfere with the performance of your application because it accesses a database on the main thread.

Not wanting to abandon analytics, I’ve been using this class ever since. It’s a useful wrapper around the GoogleAnalyticsTracker class which I thought I’d share because it’s simply very useful. It:

  • Enqueues tracking events on a background thread so that the main UI thread is not blocked.
  • Provides high-level event-categorization and filtering based on categories.
  • Records statistics on the underlying Google analytics tracker.

Using it is very simple, here’s an example:

And here’s the class which you’re welcome to use in any of your own projects.

  1. tomgibara posted this
blog comments powered by Disqus