Quickstart
Initialize Tapjoy on Android by following the Quickstart guide.
Read time 3 minutesLast updated 3 hours ago
SDK Integration
Maven (recommended)
Maven allows you to integrate Offerwall by adding a few lines to your applications build.gradle file. To use Tapjoy, add it to your build.gradle file:repositories { maven { name "Tapjoy's maven repo" url `https://sdk.tapjoy.com/` } maven { name 'Google' url 'https://maven.google.com/' } } dependencies { implementation 'com.tapjoy:tapjoy-android-sdk:14.4.0' }
Add App Permissions and Activities
The following permissions are needed:- (optional)
ACCESS_WIFI_STATE
At this point, it’s a good idea to compile and run your application to ensure that everything in your app is still working. Because we haven’t actually done anything to your application’s code, there should be no errors or changes in how your application functions.android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
AD_ID and the Google Play Families Progam
Tapjoy 12.9.0 includesplay-services-ads
play-services-ads
AD_ID
More details are available here.<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
Connect to Tapjoy
The next step is to add the Tapjoy connect code to your application. This key bit of code "turns on" the Offerwall SDK in your application.
To implement the Tapjoy connect call, you will need your Offerwall 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:
Then in your main Activity'simport com.tapjoy.Tapjoy
onCreate()
In this code you can see that we connect to Tapjoy (listening for the success, failure, and warning callbacks) and we configure two 'connect flags' (logging and user id).Hashtable<String, Object> connectFlags = new Hashtable<String, Object>(); connectFlags.put(TapjoyConnectFlag.TJC_OPTION_LOGGING_LEVEL, TJLogLevel.DEBUG); // Disable this in production builds connectFlags.put(TapjoyConnectFlag.USER_ID, "USER_ID_GOES_HERE"); // Important for self-managed currency Tapjoy.connect(getContext().getApplicationContext(), "SDK_KEY_GOES_HERE", connectFlags, new TJConnectListener() { @Override public void onConnectSuccess() { } @Override public void onConnectWarning(int code, String message) { } @Override public void onConnectFailure(int code, String message) { } });
onConnectSuccess
onConnectWarning
onConnectFailure
Flag | Description | Notes |
---|---|---|
| If this flag is set, the Offerwall SDK will use persistent IDs for advertising purposes if the advertising ID is not available. | Available in SDK versions 12.2.1 and later. |
| 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 Offerwall 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. |
Max User Level
You can tell Tapjoy how many levels there are in your game. You can set this value before or after calling connect.Tapjoy.setMaxLevel(10);
User Segment
You can identify users as part of a segment by callingsetUserSegment
Tapjoy.setUserSegment(TJSegment.VIP); Tapjoy.setUserSegment(TJSegment.PAYER); Tapjoy.setUserSegment(TJSegment.NON_PAYER); Tapjoy.setUserSegment(TJSegment.UNKNOWN);