ParselyAndroid  2.2
The Parsely Android Toolkit
Parsely for Android Documentation

Quickstart Guide

Integrating with Android Studio

To integrate mobile tracking with your Android Studio app:

  1. Copy the parselyandroid directory to your project's top-level package directory (in a default Android Studio project, this is /app/src/main/java/com.) The directory tree should look like /app/src/main/java/com/parsely/parselyandroid.
  2. In Build -> Edit Libraries and Dependencies under the Dependencies tab, use the green + to add two Library Dependencies: org.codehaus.jackson:jackson-core-lgpl:1.9.13 and org.codehaus.jackson:jackson-mapper-lgpl:1.9.13
  3. Add the following lines to your AndroidManifest.xml file:
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  4. Add the following lines to app/build.gradle:
     packagingOptions {
         exclude 'META-INF/LGPL2.1'
         exclude 'META-INF/LICENSE'
         exclude 'META-INF/NOTICE'

Using the SDK

In any file that uses the Parsely SDK, be sure to add the line

import com.parsely.parselyandroid.*;

at the top of the file.

Before using the toolkit, you must initialize the Parsely object with your public api key. This is usually best to do in the MainActivity's onCreate method.

protected void onCreate(Bundle savedInstanceState) {
    ParselyTracker.sharedInstance("", this);

The this parameter is necessary to give Parsely access to the app's context.

The Parsely toolkit maintains a queue of pageview events and periodically flushes it to the servers. This helps extend the battery life of your users' Android devices. As a result of this design, there may be some pageview events remaining in the queue at the time the user exits your app. To make sure all of the queued events are flushed to the server at this time, make sure to include a call to flush() in your main activity's onDestroy() method:

protected void onDestroy() {

To register a pageview event with Parsely, simply use the track call.


This call requires the canonical URL of the page corresponding to the post currently being viewed.