Pages

Android

Being new learner we will use some shorthand and easy steps as follows-
Step1. first of all include libGoogleAnalyticsV2.jar  in your project's /libs directory and build path

Step2. Update AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Step3. Add EasyTracker methods

Add the send methods to the onStart() and onStop() methods of each of your Activities as in the following example:
/**
 * An example Activity in your app with Analytics
 * implemented.
 */
public class myTrackedActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);EasyTracker.getInstance().setContext(this);  }

  @Override
  public void onStart() {
    super.onStart();
    ... // The rest of your onStart() code.
    EasyTracker.getInstance().activityStart(this); // Add this method.
  }

  @Override
  public void onStop() {
    super.onStop();
    ... // The rest of your onStop() code.
    EasyTracker.getInstance().activityStop(this); // Add this method.
  }
}

Step4. Create your analytics.xml file

?xml version="1.0" encoding="utf-8" ?>
<resources>
  <!--Replace placeholder ID with your tracking ID-->
  <string name="ga_trackingId">UA-XXXX-Y</string>

  <!--Enable automatic activity tracking-->
  <bool name="ga_autoActivityTracking">true</bool>

  <!--Enable automatic exception tracking-->
  <bool name="ga_reportUncaughtExceptions">true</bool>
</resources>