1

I am using the Google Analytics API for an android app. To make data requests we need to create a service object:

Analytics analytics = Analytics.builder(HTTP_TRANSPORT, JSON_FACTORY)
.setApplicationName("Hello-Analytics-API-Sample")
.setHttpRequestInitializer(credential)
.build();

What is the best way to pass this object to different activities, so I can data request for different activities? I checked the parcelable method, however, from what I understand, you need to implement that in the class whereas here I am importing the class from their API library.

Here is the article for more info: https://developers.google.com/analytics/solutions/articles/hello-analytics-api

To clarify I am using the GA API to pull data, not the SDK to collect data for my app.

Thanks

Hydar77
  • 187
  • 1
  • 2
  • 9
  • Ain't you using google analytics sdk? https://developers.google.com/analytics/devguides/collection/android/v3/ – Tarun Sep 02 '13 at 10:01
  • You can create a Google Analytics activity and extend each activity so that they will all have this functionality. This answer explains it clearly. http://stackoverflow.com/questions/3216692/google-analytics-in-android-app-dealing-with-multiple-activities/6253664 – Joel Dean Sep 02 '13 at 10:04
  • I should clarify that I am not using the SDK. I am creating an analytics app that pulls data from the Google Analytics server to my application. To make those requests I need a Google Analytics Service object: https://developers.google.com/resources/api-libraries/documentation/analytics/v3/java/latest/ – Hydar77 Sep 02 '13 at 10:42

1 Answers1

0

I did find this from google: http://developer.android.com/guide/faq/framework.html#3 . Creating a singleton class might be the way to go here. In case anyone else finds it useful

Hydar77
  • 187
  • 1
  • 2
  • 9