Quickstart

1. Dashboard Integration Guide

The Tapjoy Dashboard has a built-in Integration Guide that will walk you through the steps of a Tapjoy integration. You can use this Getting Started Guide document as a reference if you prefer or you can go directly to the Integration Guide for your most recent app.

2. SDK Integration

A. Maven (recommended)

Maven allows you to integrate Tapjoy by adding a few lines to your applications build.gradle file. To use Tapjoy simply add it to your build.gradle file:

    repositories {
      maven {
        name "Tapjoy's maven repo"
        url "https://tapjoy.bintray.com/maven"
      }
    }

    dependencies {
      api 'com.tapjoy:tapjoy-android-sdk:12.7.0@aar'
    }

B. Add App Permissions and Activities

The following permissions are needed:

  • INTERNET
  • ACCESS_NETWORK_STATE
  • ACCESS_WIFI_STATE(optional)
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

To use Tapjoy’s full functionality for the current SDK version, add these activities to the AndroidManifest.xml file in the Application block:

<activity
  android:name="com.tapjoy.TJAdUnitActivity"
  android:configChanges="orientation|keyboardHidden|screenSize"
  android:hardwareAccelerated="true"
  android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
  android:name="com.tapjoy.TJContentActivity"
  android:configChanges="orientation|keyboardHidden|screenSize"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:hardwareAccelerated="true" />

You will also need to add the same configChanges to your App’s Manifest activity:

  android:configChanges="orientation|keyboardHidden|screenSize"

As part of your Google Play Services integration, you will have to add the following:

<meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />

C. Proguard

IMPORTANT: If you’re Publishing and using Proguard add these lines to your configuration file:

-keep class com.tapjoy.** { *; }
-keep class com.moat.** { *; }
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keep class com.google.android.gms.ads.identifier.** { *; }
-dontwarn com.tapjoy.**

At this point, it’s a good idea to compile and run your application to ensure that everything in your app is still working. Since we haven’t actually done anything to your application’s code, there should be no errors or changes in how your application functions.

3. Connect to Tapjoy

The next step is to add the Tapjoy connect code to your application. This key bit of code "turns on" the Tapjoy SDK in your application.

The Tapjoy connect call is extremely important, as none of Tapjoy’s products or functionality will work if it is not implemented correctly.

To implement the Tapjoy connect call, you will need your Tapjoy SDK Key for the application you are integrating. To find this, navigate to your application in the Tapjoy dashboard, and click the "Settings" button on the top navigation bar. Navigate to "App Settings" and you will find the SDK Key at the bottom of the page.

Now it's time to write some code. Import Tapjoy in to your Activity:

java
  import com.tapjoy.Tapjoy

Then in your main Activity's onCreate() method connect to Tapjoy:

java
  Hashtable<String, Object> connectFlags = new Hashtable<String, Object>();
  connectFlags.put(TapjoyConnectFlag.ENABLE_LOGGING, "true"); // Disable this in production builds

  Tapjoy.connect(getApplicationContext(), "SDK_KEY_GOES_HERE", connectFlags, new TJConnectListener() {
        @Override
        public void onConnectSuccess() {
          this.onConnectSuccess();
        } 

        @Override
        public void onConnectFailure() {
          this.onConnectFailure();
        }
   });

For a complete code example please refer to the sample 'EasyApp' provided with the sdk.

For an explanation of the connectFlags, Please see the Java SDK Reference.

The two most common and useful for Publishers will be ENABLE_LOGGING, and USER_ID. Setting the USER_ID at connect is necessary to have the appropriate User ID set for the placement AppLaunch. For Push2Earn placements it is also important to have this set before defining the placement.

Some of the connect flags are useful to help publishers control how Tapjoy uses the various Android Identifiers supplied by the operating system:

  • ALLOW_LEGACY_ID_FALLBACK (available in SDK versions 12.2.1 and later) If this flag is set, the Tapjoy SDK will use persistent IDs for advertising purposes if the advertising ID is not available.
  • DISABLE_ANDROID_ID_AS_ANALYTICS_ID If this flag is set, the ID that Tapjoy uses for analytics purposes is not a copy of the Android ID, but instead a randomly generated string of characters. Releasing a build that changes the setting of this flag from the previous version may result in some of your existing users being seen as new users by Tapjoy’s analytics tools.
  • DISABLE_ADVERTISING_ID_CHECK By default, Tapjoy’s Android SDK checks for the existence of the Google Advertising Identifier and will fail to initialize if it does not find it. By setting this flag, you can disable this check so that the Tapjoy SDK initializes even if there is no Google Advertising Identifier present. This is useful when Google Play Services is not present in the app, such as when you are making a build for release in a non-Google Play app store.

Now compile and run your application.

In the Tapjoy Dashboard, if you click on the "Analytics" from the top navigation bar and then "Real-time" tab in the navigation bar on the left, you should see some activity from your application moments after you run it.

Congratulations! You now have Tapjoy working in your application.