未定义 admob 插页式广告侦听器
admob interstital ad listener not defined
我有一个 android 项目,其中包含运行良好的插页式广告,在我更新 admob 库后,听众无法正常工作并显示未定义
//setAdListener not defined
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Toast.makeText(MyActivity.this,
"The interstitial is loaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onAdClosed() {
// Proceed to the next level.
goToNextLevel();
}
});
我已经搜索了新的实现文档,但没有找到与我想使用 onAdClosed 方法打开新意图的这种情况类似的内容
对不起我的英语 (:
我正在使用:
implementation 'com.google.android.gms:play-services-ads:20.2.0'
在class...
AdRequest adRequest = new AdRequest.Builder().build();
InterstitialAd mInterstitialAd = null;
调用方式:
public void adInterstitialCall(){
if(mInterstitialAd == null){
InterstitialAd.load(this,this.getString(R.string.ad_interstitial), adRequest, new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) { mInterstitialAd = interstitialAd; }
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
mInterstitialAd = null;
}
});
}
}
显示和关闭侦听器:
public void adInterstitialShow(){
if (mInterstitialAd != null) {
mInterstitialAd.show(this);
mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){
@Override
public void onAdDismissedFullScreenContent() {
mInterstitialAd = null;
adInterstitialCall();
}
});
}
else{adInterstitialCall();}
}
我有一个 android 项目,其中包含运行良好的插页式广告,在我更新 admob 库后,听众无法正常工作并显示未定义
//setAdListener not defined
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Toast.makeText(MyActivity.this,
"The interstitial is loaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onAdClosed() {
// Proceed to the next level.
goToNextLevel();
}
});
我已经搜索了新的实现文档,但没有找到与我想使用 onAdClosed 方法打开新意图的这种情况类似的内容
对不起我的英语 (:
我正在使用:
implementation 'com.google.android.gms:play-services-ads:20.2.0'
在class...
AdRequest adRequest = new AdRequest.Builder().build();
InterstitialAd mInterstitialAd = null;
调用方式:
public void adInterstitialCall(){
if(mInterstitialAd == null){
InterstitialAd.load(this,this.getString(R.string.ad_interstitial), adRequest, new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) { mInterstitialAd = interstitialAd; }
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
mInterstitialAd = null;
}
});
}
}
显示和关闭侦听器:
public void adInterstitialShow(){
if (mInterstitialAd != null) {
mInterstitialAd.show(this);
mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){
@Override
public void onAdDismissedFullScreenContent() {
mInterstitialAd = null;
adInterstitialCall();
}
});
}
else{adInterstitialCall();}
}