A
A
Andrey Golubkov2014-11-23 14:45:48
Google
Andrey Golubkov, 2014-11-23 14:45:48

How to work with the new version of Google Analytics in android?

The new version of the Google Analytics SDK https://developers.google.com/analytics/devguides/...
It is shown on the example of the Mobileplayground application.
I can't figure out how to do this in my application.
I created the AnalyticsSampleApp class, in the MainActivity class I write Tracker t = ((AnalyticsSampleApp)getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER); and eclips tells me that there is a getActivity () error. (method not defined for main activity).
I searched on the Internet how to work, I did not find it (I found it, but there are old versions).
Can anyone provide a link or explain the process of embedding Google Analytics into an android application?
The version of SDK analytics at the moment is 4.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anyd3v, 2014-11-23
@Android97

"Eclipse tells me that there is a getActivity() error. (Method not defined for Main Activity)."
To mine it is logical that this method is not defined in the activity. try
((AnalyticsSampleApp)this.getApplication()).getTracker (just in case getActivity is replaced with this )
Soon, every compilation error will raise a question on the toaster, at least create plugins for the IDE.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question