如何在新 API 中重新加载激励广告?
How can I reload rewarded ad in new API?
我希望当用户观看激励广告时重新加载它以备下次使用。
代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_watch);
MobileAds.initialize(this);
adRequest = new AdRequest.Builder().build();
RewardedAd.load(WatchActivity.this, getString(R.string.reward), adRequest, new RewardedAdLoadCallback() {
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
mRewardedAd = null;
}
@Override
public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
mRewardedAd = rewardedAd;
mRewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
@Override
public void onAdShowedFullScreenContent() {
mRewardedAd = null;
}
@Override
public void onAdDismissedFullScreenContent() {
}
});
}
});
}
内部点击监听器
if (mRewardedAd != null) {
mRewardedAd.show(WatchActivity.this, new OnUserEarnedRewardListener() {
@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
//I want to reload ad after watch the ad, How can I do it?
}
});
}
我在 Rewarded Ads 中找不到关于重新加载广告的任何内容。
private void loadRewardedVideoAd() {
RewardedAd.loadAd(getString(R.string.reward),
new AdRequest.Builder().build());
}
@Override
public void onRewarded(RewardItem rewardItem) {
//ProcessRewardedItem and then reload
loadRewardedVideoAd();
}
我希望当用户观看激励广告时重新加载它以备下次使用。
代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_watch);
MobileAds.initialize(this);
adRequest = new AdRequest.Builder().build();
RewardedAd.load(WatchActivity.this, getString(R.string.reward), adRequest, new RewardedAdLoadCallback() {
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
mRewardedAd = null;
}
@Override
public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
mRewardedAd = rewardedAd;
mRewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
@Override
public void onAdShowedFullScreenContent() {
mRewardedAd = null;
}
@Override
public void onAdDismissedFullScreenContent() {
}
});
}
});
}
内部点击监听器
if (mRewardedAd != null) {
mRewardedAd.show(WatchActivity.this, new OnUserEarnedRewardListener() {
@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
//I want to reload ad after watch the ad, How can I do it?
}
});
}
我在 Rewarded Ads 中找不到关于重新加载广告的任何内容。
private void loadRewardedVideoAd() {
RewardedAd.loadAd(getString(R.string.reward),
new AdRequest.Builder().build());
}
@Override
public void onRewarded(RewardItem rewardItem) {
//ProcessRewardedItem and then reload
loadRewardedVideoAd();
}