HMS-Core / hms-ads-demo-java

HUAWEI Ads SDK sample code. HUAWEI Ads SDK provides the banner, native, rewarded, interstitial and splash ad formats for integration.
https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/ads-sdk-introduction?ha_source=hms1
Apache License 2.0
57 stars 20 forks source link

Violation about Preventing invalid impressions #20

Open AmiriOS2019 opened 2 years ago

AmiriOS2019 commented 2 years ago

I used the same code demo from Native Ads in my app and the banner displays correctly but when I published it on AppGallery I got the following message:

An ad cannot be displayed repeatedly for one request. After being displayed, the ad needs to be loaded again in real time for the next request. [Recommended] The ad object on each page is independent. You need to use the createXX method to create ads and register a callback.

Please, has anyone had the same problem with this code being used?

ttljtw commented 2 years ago

Yes, it is recommended to create a new one at a time, as in the demo.

AmiriOS2019 commented 2 years ago

I updated my code today and the ads are showing correctly on the phone. but i'm not sur if it's the correct way to avoid the message : An ad cannot be displayed repeatedly for one request

Please have a look https://github.com/AmiriOS2019/myfiles2/blob/main/MyActivity.java

ttljtw commented 2 years ago

Look at the code and I think your problem can be solved. But, I don't think it's handled right here, why did you destory ad just loaded?

AmiriOS2019 commented 2 years ago

Thank you ttljtw for your remark. I put it first like on the demo code link, but after seeing the documentation I noticed that I should destroy the native ad after displaying it, so I move it after adScrollView.addView(nativeView); but what I don't understand, why the value of nativeAd is not null after i have destroyed it