Rewarded Video Ads | Android

Similar to interstitial ad units, rewarded video ads are shown in full-screen mode and can be placed before, in-between or after the app content.

The video ad will be loaded in the background and will be waiting for a signal to show up.

1) The rewarded video player first requires the following activity declaration in your AndroidManifest.xml:

<activity android:name="com.smaato.soma.video.VASTAdActivity" android:configChanges="keyboardHidden|orientation|screenSize" />

2) You will then need to instantiate a rewarded video object in the activity where you want to show rewarded video ads and implement the RewardedVideoListener interface to have more control over the rewarded video ads.

import com.smaato.soma.video.RewardedVideo;
import com.smaato.soma.video.RewardedVideoListener;

public class MyActivity extends Activity implements RewardedVideoListener {

    RewardedVideo rewardedVideo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rewardedvideo_sample);
        rewardedVideo = new RewardedVideo(MyActivity.this);
    }

        // Called when the banner has been loaded.
        @Override
        public void onReadyToShow() {
            rewardedVideo.show();   // call this when to show the RewardedVideo ad.
        }

        // Called when the ad will be displayed.
        @Override
        public void onWillShow() { }

        // Called when the RewardedVideo or the EndCard is clicked after video completion
        @Override
        public void onWillOpenLandingPage () { }

        // Called when the ad is closed.
        @Override
        public void onWillClose () { }

        // Called when there is No ad or Ad failed to Load
        @Override
        public void onFailedToLoadAd () { }

        @Override
        public void onRewardedVideoStarted () { }

        @Override
        public void onFirstQuartileCompleted () { }

        @Override
        public void onSecondQuartileCompleted () { }

        @Override
        public void onThirdQuartileCompleted () { }

        // Called when the Video ad display completed.
        @Override
        public void onRewardedVideoCompleted () { } // TODO

    } 

3) You will then need to provide the SDK with your Smaato Publisher ID and AdSpace IDs. Please use the following code:

rewardedVideo.getAdSettings().setPublisherId(REPLACE_WITH_YOUR_PUBLISHER_ID);
rewardedVideo.getAdSettings().setAdspaceId(REPLACE_WITH_YOUR_ADSPACE_ID);

4) Last, to load a new video ad, use the following method:

rewardedVideo.asyncLoadNewBanner();

Destroying the Video Ad

When you finish using a video ad format and want to clean up memory usage, please call the destroy() method:

@Override
public void onDestroy() {
 videoAd.destroy();
 super.onDestroy();
} 

Modified: July 18, 2019 at 2:56 pm