146 percent Russian
146 percent Russian

Reputation: 2096

Activity without onStart and onStop + Google Analytics

I have a problem. All my activities are without methods onStart and onStop. All the code is inside onCreate. All activities are ended with finish();

But I want to integrate Google analytics inside my project. The instructions are following:

public void onStart() {
    super.onStart();
      EasyTracker.getInstance().activityStart(this); // Add this method.
  }

  @Override
  public void onStop() {
    super.onStop();

     EasyTracker.getInstance().activityStop(this); // Add this method.
  }

Shall I just create these methods and leave them empty? Or I can put EasyTracker methods inside onCreate ?

Upvotes: 1

Views: 339

Answers (1)

donfuxx
donfuxx

Reputation: 11323

just add this methods code like you posted in your question.

The thing is: All Activities have onStart() and onStop() methods, you are just overriding them to add some additional code (here the analytics tracker) when the Activity changes its state.

Take a look at this activiy life-cycle diagram here: http://developer.android.com/training/basics/activity-lifecycle/stopping.html


enter image description here

Upvotes: 1

Related Questions