Class RewardedAd

com.yandex.mobile.ads.rewarded

java.lang.Object ⇽ RewardedAd

public class RewardedAd

This class is responsible for loading rewarded video ads.

Constructors

RewardedAd(@NonNull final Context context)

Creates an object of the RewardedAd class programmatically.

Methods

void destroy()

Deletes an object of the RewardedAd class and releases all resources in use.

String getBlockId()

Returns the unique ID of the ad placement.

boolean isLoaded()

Returns the result of ad loading.

void loadAd(final AdRequest adRequest)

Starts ad loading in the background.

void setBlockId(final String blockId)

Sets the unique ID of the ad space.

void setRewardedAdEventListener(@Nullable final RewardedAdEventListener rewardedAdEventListener)

Specifies an object of the RewardedAdEventListener class for getting notifications about events that occur during the lifecycle of a rewarded ad.

void setUserId(final String userId)

Sets the unique user ID.

void shouldOpenLinksInApp(final boolean shouldOpenLinksInApp)

Sets the method for opening links from the application.

void show()

Displays the ad if it was loaded.

Constructor Detail

RewardedAd

public RewardedAd (@NonNull final Context context)

Creates an object of the RewardedAd class programmatically.

Parameters:
context

An object of the Context system class.

Method Detail

destroy

public void destroy ()

Deletes an object of the RewardedAd class and releases all resources in use.

Note.

Don't use an object of the RewardedAd class after calling this method.

getBlockId

public String getBlockId ()

Returns the unique ID of the ad placement.

Returns:

Unique ID of the ad placement.

isLoaded

public boolean isLoaded ()

Returns the result of ad loading.

Returns:

If true, the ad has been successfully loaded and is ready to be displayed. If ad loading failed or the ad isn't ready to be displayed, the false value is returned.

loadAd

public void loadAd (final AdRequest adRequest)

Starts ad loading in the background.


NOTE:  
The identifier of the block ID advertising block must be passed before calling this method.
Parameters:
adRequest

An object of the AdRequest class with data for a targeted ad request.

setBlockId

public void setBlockId (final String blockId)

Sets the unique ID of the ad space.

Parameters:
blockId

Unique ID of the ad placement.

Throws:

throwIllegalArgumentIfEmpty

An empty BlockID or the null value is set.

throwIllegalArgumentIfNotEmpty

Attempt to reset the BlockID for the current object of the RewardedAd class.

setRewardedAdEventListener

public void setRewardedAdEventListener (@Nullable final RewardedAdEventListener rewardedAdEventListener)

Specifies an object of the RewardedAdEventListener class for getting notifications about events that occur during the lifecycle of a rewarded ad.

Parameters:
rewardedAdEventListener

An object of the RewardedAdEventListener class.

setUserId

public void setUserId (final String userId)

Sets the unique user ID.

Parameters:
userId

Unique user ID. Created in the Partner interface.

shouldOpenLinksInApp

public void shouldOpenLinksInApp (final boolean shouldOpenLinksInApp)

Sets the method for opening links from the application.

Parameters:
shouldOpenLinksInApp
How to open links from the app. Acceptable values:
  • true — Open links in the app browser.

  • false — Open links in the device browser.

The default value is false.

show

public void show ()

Displays the ad if it was loaded.