gpt4 book ai didi

android - InterstitialAd 监听器 onAdClicked 不工作

转载 作者:太空宇宙 更新时间:2023-11-03 13:42:59 24 4
gpt4 key购买 nike

All other listeners of InterstitialAd are working but only onAdLoaded not working.

i have set toast for all listener but onAdLoaded only not getting called but other all are working correctly.

why only onAdClicked() is not working what's wrong with this method

代码

    public class TestActivity extends AppCompatActivity {
InterstitialAd mInterstitialAd;
AdRequest adRequest;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_activity);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-9547225037870226/6863551510");
adRequest = new AdRequest.Builder()
.build();
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int i) {
super.onAdFailedToLoad(i);
Toast.makeText(TestActivity.this, "ad failed to load", Toast.LENGTH_SHORT).show();


}

public void onAdLoaded() {
Toast.makeText(TestActivity.this, "ad loaded", Toast.LENGTH_SHORT).show();

showInterstitial();
}


@Override
public void onAdOpened() {
super.onAdOpened();
Toast.makeText(TestActivity.this, "ad open", Toast.LENGTH_SHORT).show();

}

@Override
public void onAdImpression() {
super.onAdImpression();
Toast.makeText(TestActivity.this, "ad impression", Toast.LENGTH_SHORT).show();

}

@Override
public void onAdClosed() {
super.onAdClosed();
Toast.makeText(TestActivity.this, "ad close", Toast.LENGTH_SHORT).show();

}
@Override
public void onAdClicked() {
super.onAdClicked();
Toast.makeText(TestActivity.this, "ad clicked", Toast.LENGTH_SHORT).show();

}

});
}
private void showInterstitial() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}
}

最佳答案

onAdClicked 不适用于插页式广告,也不会为它们调用。来自documentation :

Called when a click is recorded for an ad. At the current time, this method is only used with native ads originating from Google in one of the system-defined formats (App Install or Content).

不过,如果您想知道用户何时点击了插页式广告,您可以改用 onAdLeftApplication 方法。点击将导致焦点离开应用程序,因此这是一种可靠的了解方式。

关于android - InterstitialAd 监听器 onAdClicked 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47814295/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com