Android Rewarded Video Integration

Android Rewarded Video Documentation

Plug in Your Rewarded Video Profile

Launching a rewarded video requires at least three parameters or data points: your publisher ID, the profile ID associated with a Rewarded Video profile that you have created, and the unique ID of the user who will be watching the rewarded video.

You can get your profile ID and publisher ID after setting up your Rewarded Video profile.


Showing the Rewarded Video

Before proceeding make sure you have integrated the SDK in your project.

To display a rewarded video, initialize and start a new Intent with the values you gathered above for Publisher ID and Profile ID, along with the end user's unique ID for subId1 in the following way:

static final int PLAY_REWARDED_VIDEO = 1;

String publisherId = "32740";
String profileId = "365";
String subid1 = "demo_subid1";

public void OnRewardedVideoClick(View view) {
  final Intent rewardedVideoIntent = RewardedVideoActivity.getIntentForRewardedVideo(this, pubId, adwallId, subId1);
  final Context context = this;
  final RewardVideoListener listener = new RewardVideoListener() {
    @Override
    public void onSuccess(Intent intent) {
      // The response may take some time due to network activity. So you may want to show the activity indicator while you wait for the response.
      // On success, show the rewarded video activity.
      RewardedVideoActivity.showVideo(intent, context ,this);
    }

    //onFailure gets called on following scenarios:
    //1. If the loadVideoData fails to get any video data.
    //2. If loadVideoData succeeds but internet connectivity is lost before playing the video.
    //3. If after watching the video the user couldn't be credited for some reason.

    @Override
    public void onFailure(int responseCode, String message) {
      // Handle error
      Log.d(TAG, responseCode+" "+ message);
    }

    //If the user manually closes the media player.
    @Override
    public void onError(int errorCode, int extra) {
      //Media player error call back
      Log.d(TAG, "OnError : " + errorCode+ " extra: " + extra);
    }

    //onClosed callback is called when the user closes the post video pop-up.
    @Override
    public void onClosed() {
      Log.d(TAG, "Video closed");
    }
  };
  RewardedVideoActivity.loadVideoData(listener, rewardedVideoIntent, this);
}


Detecting Video Completion

In addition to the postback we make when the video is watched, the following example will show how to detect the end of the video play so you can then visually credit the user in your application, show a message or complete any other action that you may want to when the video is completed.If any error occurs while creating postback, then 'onFailure()' is called.

      final RewardVideoListener listener = new RewardVideoListener() {
        @Override
        public void onFailure(int responseCode, String message) {
          // Handle error
          Log.d(TAG, responseCode+" "+ message);
        }

        @Override
        public void onRerwarded() {
          Log.d(TAG, "User was successfully credited");
        }
      };
      

You can also download a sample Android Studio project showing how to integrate our Rewarded Video.

Rate Limiting Users

To limit a user's ability to watch rewarded videos to a certain number of times, it is best to maintain an external counter and hide the call-to-action after the user has initiated the action a certain number of times.

Eclipse-ADT

Integrate Google Play Services

Our SDK utilizes Google Play Services to access the Google Advertising ID and it will not compile without Google Play Services integrated into your Eclipse project. If you have not integrated Google Play Services in your project yet, please follow the Google Play Services integration guide.

The AndroidManifest.xml file should contain the following activity declaration and permissions:

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

<activity
        android:name="com.adscendmedia.videosdk.RewardedVideoActivity"
        android:screenOrientation="landscape">
</activity>

Need help with your integration?

If you have any questions about integrating our Offer Wall into your project, shoot us an email at
SDKsupport@adscendmedia.com