hms-ads-demo-java
hms-ads-demo-java copied to clipboard
Violation about Preventing invalid impressions
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?
Yes, it is recommended to create a new one at a time, as in the demo.
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
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?
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