Rewarded video

Rewarded is an ad video format that is displayed in a full screen window. After viewing the full ad, the user receives a reward. The reward can be minutes of an application service, delivery of virtual currencies of the game or application, one more try, an extra life, etc.

Example of minimal use

The minimal usage example is practical and easy to display ads. But in video, especially rewarded, the right thing to do is preload the ad, wait for the right moment to show it and reward the user for seeing it. To do this, listeners must be used.

public class RewardedActivity extends Activity {
    TappxRewardedVideo rewardedVideo;
    Boolean loading = false;
    Boolean isLoad = false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        view.findViewById(R.id.button_load).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                loadRewarded();
            }
        });
        view.findViewById(R.id.button_show).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                 if (rewardedVideo != null) {
                   rewardedVideo.show();
                 }
        });
    }
    private void loadRewarded() {
        if (loading) return;
        loading = true;
        isLoad = false;
        if (rewardedVideo != null) {
            rewardedVideo.destroy();
        }
        rewardedVideo = new TappxRewardedVideo(getActivity(), appKey);
        rewardedVideo.setListener(rewardedListener);
        rewardedVideo.loadAd();
    }
    private TappxRewardedVideoListener rewardedListener = new TappxRewardedVideoListener() {
        @Override
        public void onRewardedVideoLoaded(TappxRewardedVideo rewardedVideo) {
            loading = false;
            isLoad = true;
        }
        @Override
        public void onRewardedVideoLoadFailed(TappxRewardedVideo rewardedVideo, TappxAdError errorCode) {
            loading = false;
        }
        @Override
        public void onRewardedVideoCompleted(TappxRewardedVideo rewardedVideo) {
            //In this place you have to reward the user
        }
    };
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (rewardedVideo!= null) rewardedVideo.destroy();
    }
}

To allow more control, ads can also be shown with four steps: loadAd, isReady, show and onRewardedVideoCompleted.

rewardedVideo.loadAd();

loadAd load all the necessary information to be able to display the ad.

rewardedVideo.isReady();

isReady it is to check that the ad is ready to be shown.
It receives a "true" when it is ready and a "false" when it is not.

rewardedVideo.show();

show displays the previously uploaded video ad.

public void onRewardedVideoCompleted(TappxRewardedVideo rewardedVideo) {
    //In this place you have to reward the user
}

onRewardedVideoCompleted listener allows the user to to reward the user.

This division is necessary in rewarded video, for example, in a game you can load the ad while the user plays a level and later show it when the level ends or pauses the game. In video ads it is much more relevant than in display since the ad is heavier and may take longer to load. For this reason, the ideal is to use the preload of the ad before it is going to be shown. Also, this will improve the user experience.

Rewarded video listeners

For the use of rewarded video, listeners are very important to be able to reward the user for having seen the video in its entirety.

In order to listen to the events we establish a listener with the rewardedVideo.setListener() method:

rewardedVideo.setListener(new TappxRewardedVideo() {
    @Override
    public void onRewardedVideoLoaded(TappxRewardedVideo rewardedVideo) {
        Log.v("Tappx", "Tappx: onRewardedVideoLoaded");
    }

    @Override
    public void onRewardedVideoLoadFailed(TappxRewardedVideo rewardedVideo, TappxAdError tappxAdError) {
        Log.v("Tappx", "Tappx: onRewardedLoadFailed");
    }

    @Override
    public void onRewardedVideoStart(TappxRewardedVideo rewardedVideo) {
        Log.v("Tappx", "Tappx: onRewardedVideoStart ");
    }

    @Override
    public void onRewardedVideoClicked(TappxRewardedVideo rewardedVideo) {
        Log.v("Tappx", "Tappx: onRewardedVideoClicked");
    }

    @Override
    public void onRewardedVideoPlaybackFailed(TappxRewardedVideo rewardedVideo) {
        Log.v("Tappx", "Tappx: onRewardedVideoPlaybackFailed");
    }

    @Override
    public void onRewardedVideoClosed (TappxRewardedVideo rewardedVideo) {
        Log.v("Tappx", "Tappx: onRewardedVideoClosed");
    }

    @Override
    public void onRewardedVideoCompleted (TappxRewardedVideo rewardedVideo) {
        Log.v("Tappx", "Tappx: onRewardedVideoCompleted");
    }

});

Tappx © 2020