Integrating Rewarded Ads SDK

This section explains the steps to integrate the Rewarded Ads SDK with your development environment.

To get started, download the Rewarded Ads SDK libraries and add them to your development environment.

The SDK package contains the Rewarded Ads SDK files and the sample app.

Add SDK Libraries

1. Extract the compressed Rewarded Ads SDK file and locate the .aar file in the package:


2. Add the following dependency to the build.gradle file of your game:

 dependencies {
         implementation fileTree(dir: 'libs', include: ['*.aar'])

Initialize the Rewarded Ads SDK

Before your app can show the ads, you must initialize the SDK from the onCreate method of your app’s main activity.

To initialize the SDK, call the RewardsClient.initialize() function. Once the initialisation is complete, the function will also generate a callback on the completion listener.

Note: You should initialize the SDK only once, ideally at app launch.

The following code segment illustrates this implementation:

public class MainActivity extends AppCompatActivity {
 public static final String TAG = "RewardsTest";
 public Button showAdButton;

 protected void onCreate(Bundle savedInstanceState) {
     showAdButton = findViewById(;

     RewardsClient.initialize(this, new OnInitializationCompleteListener() {
         public void onInitializationComplete(InitializationStatus initializationStatus) {
             Log.d(TAG, "onInitializationComplete: " + initializationStatus);

             if (initializationStatus.getState().equals(State.NOT_READY)) {
                 Log.d(TAG, "onInitializationComplete: error");
                 // retry creating rewardsClient

Show Rewarded Ads

Once the SDK has been successfully initialized, you can now show the in-app rewarded ads.

Based on your requirement, you can display the rewarded ads in your app by calling the RewardsClient.showAd() function of the rewarded ads SDK. Rewarded Ads utilizes the following callback functions to inform your app about the status of the rewarded ad request:

  • void onAdShownToUser(); – Ad is displayed on the user’s screen.
  • void onAdFailedToLoad(String reason); – Ad failed to load.
  • void onAdDismissed(boolean rewardEarned); – Ad was dismissed by the user. Continue with app operations.
  • void onUserEarnedReward(); – User earned a reward.

The following code segment illustrates the above-listed callback functions and their implementation:

showAdButton.setOnClickListener(view -> {
    RewardsClient.showAd(this, new AdStatusListener() {
 // Ad is displayed on the User's screen
        public void onAdShownToUser() {
            Toast.makeText(getBaseContext(), "Ad is displayed on the user’s screen", Toast.LENGTH_LONG).show();
 // Ad failed to load
        public void onAdFailedToLoad(String s) {
            Log.d(TAG, "onAdFailedToLoad() called with: s = [" + s + "]");
            Toast.makeText(getBaseContext(), "Ad failed to load", Toast.LENGTH_SHORT).show();

 //Ad was dismissed by the user; continue with app operations.
        public void onAdDismissed(boolean rewardEarned) {
            if (rewardEarned)
                Toast.makeText(getBaseContext(), "Congrats, you earned a reward", Toast.LENGTH_LONG).show();
                Toast.makeText(getBaseContext(), "Ad was dismissed - No reward this time!", Toast.LENGTH_LONG).show();

 //User earned a reward
        public void onUserEarnedReward() {
            Log.d(TAG, "rewardEarned");

Table of Contents

Integrating Rewarded Ads SDK

Table of Contents

Document Rev. 1.0

Text copied to clipboard
Questions? Please reach out to us at