我正在尝试创建一个新的分隔实例,而不是从两个不同广告单元中加载2个不同视频的共享实例,例如:
RewardedVideoAd ga1 = new RewardedVideoAd();
RewardedVideoAd ga2 = new RewardedVideoAd();
任何想法都表示赞赏
不要一次请求多个添加,因为它会影响用户体验。相反,你可以这样做。
请求一个添加。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713"); //your key
// Use an activity context to get the rewarded video instance.
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
}
private void loadRewardedVideoAd() {
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
}
并将它显示在您想要使用的地方
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
使用它之后,在onRewardedVideoAdClosed方法上
@Override
public void onRewardedVideoAdClosed() {
// Load the next rewarded video ad.
loadRewardedVideoAd();
}
希望能帮助到你 !!欲了解更多信息,请访问official documentation。