Interstitial/Rewarded Ads in Android

The implementation of interstitial and rewarded ads (banner and video) is the same. You have to choose the zone type in the panel.

Creating a Zone

First, create a zone from the Yelloadwise panel and use the zoneId when requesting or showing an ad.

Requesting Ads

To request an ad in your application, use the following method:

Yelloadwise.requestAd(CONTEXT,
        ZONE_ID,
        new YelloadwiseAdRequestOptions(),
        new YelloadwiseAdRequestListener() {
            @Override
            public void onAdAvailable(String adId) {
              // KEEP adId
            }

            @Override
            public void onError(String message) {
            }
        });

The first argument is CONTEXT.
The second argument is the ZONE_ID which you can get from your panel.
The third argument OPTIONS is of type YelloadwiseAdRequestOptions. You can configure your ad request with this argument. The fourth argument is YelloadwiseAdRequestListener.

The details of YelloadwiseAdRequestListener methods are shown in the table below:

FunctionalityMethod
The requested ad is ready to be shown. The ad id is in the adId variableonAdAvailable
An error has occured and you can see the error message in the message variableonError

Request Options

You can change the way a video is cached with the help of the argument options, such as the lines below:

YelloadwiseAdRequestOptions options = new YelloadwiseAdRequestOptions();
options.setCacheType(CACHE_TYPE);

The CACHE_TYPE attribute can take the values below:

DescriptionValue
It starts to download the video while showing the adYelloadwiseAdRequestOptions.CACHE_TYPE_STREAMED
It downloads the video before showing the adYelloadwiseAdRequestOptions.CACHE_TYPE_CACHED

To lower the data usage, only use the CACHE_TYPE_CACHED option when the probability of user watching the ad is high.

Showing Ads

You can start showing the ad using the following lines of code:

Yelloadwise.showAd(CONTEXT,
        ZONE_ID,
        AD_ID,
        new YelloadwiseShowOptions(),
        new YelloadwiseAdShowListener() {
            @Override
            public void onOpened() {
            }

            @Override
            public void onClosed() {
            }

            @Override
            public void onError(String message) {
            }

            @Override
            public void onRewarded(boolean completed) {
            }
        });

The first argument is CONTEXT. The second argument is ZONE_ID, which you used to request an ad.
The third argument is AD_ID, which you get in the onAdAvailable callback method. The fourth argument is YelloadwiseShowOptions that you can use to configure how to show your ad.
The fifth argument is YelloadwiseAdShowListener that you can use to follow the steps of showing the ad.

The YelloadwiseAdShowListener methods are shown in the table below:

FunctionalityMethod
It is called when the ad is openedonOpened
It is called when the ad is closedonClosed
It is called when an error occurs during the process of showing the adonError
It shows the status of receiving the rewarded in the rewarded adsonRewarded

Show Options

You can configure how to show your ad with the help of the showOptions argument.

YelloadwiseShowOptions showOptions = new YelloadwiseShowOptions();
showOptions.setBackDisabled(true|false);
showOptions.setImmersiveMode(true|false);
showOptions.setShowDialog(true|false);
showOptions.setRotationMode(ROTATION_MODE);

You can give each of the methods above true or false to enable or disable that functionality. The possible values for ROTATION_MODE is explained further down.

The functionality of each method is explained in the table below:

FunctionalityMethod
Disabling the back button while showing the adsetBackDisabled
Enabling the immersive mode while showing the adsetImmersiveMode
Showing a warning dialog while closing the ad before it finishes showingsetShowDialog
Determining the rotation mode of the phone when the ad is displayedsetRotationMode

The setRotationMode attribute can take the values below:

DescriptionValue
VerticalYelloadwiseShowOptions.ROTATION_LOCKED_PORTRAIT
HorizontalYelloadwiseShowOptions.ROTATION_LOCKED_LANDSCAPE
Based on the state of the phoneYelloadwiseShowOptions.ROTATION_UNLOCKED
Reversed verticalYelloadwiseShowOptions.ROTATION_LOCKED_REVERSED_PORTRAIT
Reversed horizontalYelloadwiseShowOptions.ROTATION_LOCKED_REVERSED_LANDSCAPE

Getting The Result of Rewarded Ads

If the completed variable in the rewarded method is true in the rewarded ads, you can give the user her/his reward.