I'm trying to integrate the interstitial ad from Huawei Ads, when I click on (X) or back button to close the ad, for some reason the Toast inside onAdClosed method is not showing.
huaweiInterstitialAd = new InterstitialAd(MainActivity.this);
huaweiInterstitialAd.setAdId("teste9ih9j0rc3");
private void showHuaweiInterstitial() {
if (huaweiInterstitialAd != null && huaweiInterstitialAd.isLoaded()) {
huaweiInterstitialAd.show(MainActivity.this);
}
}
public void loadHuaweiInterstitialAd() {
huaweiInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
showHuaweiInterstitial();
}
@Override
public void onAdFailed(int errorCode) {
Log.d(TAG, "Ad load failed with error code: " + errorCode);
}
@Override
public void onAdLeave() {
super.onAdLeave();
Log.d(TAG, "onAdLeave");
}
@Override
public void onAdClosed() {
super.onAdClosed();
Toast.makeText(MainActivity.this, "Ad Closed", Toast.LENGTH_SHORT).show();
}
@Override
public void onAdClicked() {
Log.d(TAG, "onAdClicked");
super.onAdClicked();
}
@Override
public void onAdOpened() {
Log.d(TAG, "onAdOpened");
super.onAdOpened();
}
});
AdParam adParam = new AdParam.Builder().build();
huaweiInterstitialAd.loadAd(adParam);
}
The problem only occurs if you use:
implementation 'com.huawei.hms:ads:3.4.46.300'
But everything works fine with :
implementation 'com.huawei.hms:ads-lite:13.4.46.300'