hms-ads-demo-java icon indicating copy to clipboard operation
hms-ads-demo-java copied to clipboard

Violation about Preventing invalid impressions

Open AmiriOS2019 opened this issue 3 years ago • 4 comments

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?

AmiriOS2019 avatar Nov 08 '21 17:11 AmiriOS2019

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

ttljtw avatar Nov 09 '21 06:11 ttljtw

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

AmiriOS2019 avatar Nov 09 '21 12:11 AmiriOS2019

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?

ttljtw avatar Nov 10 '21 01:11 ttljtw

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

AmiriOS2019 avatar Nov 10 '21 11:11 AmiriOS2019