if-else
used for check is interstitial ad
loaded or not. If not loaded then startIntent
by else
. (code is below).
Problem(see Logcat): If Ad not loaded then second activity
open via else
part then after some seconds AdListener
run that is in if
part Interstitial ad
pop-up automatically. [this is against to Ad policy]
2020-11-22 01:26:46.761 12278-12278/com.udai.aadharloan.kredit.finance.pmscheme E/HomeActivity: ===== BTN 1 ELSE PART
2020-11-22 01:26:48.631 12278-12278/com.udai.aadharloan.kredit.finance.pmscheme E/HomeActivity: ===== AdListener : Ad loaded and then show.
2020-11-22 01:26:48.731 12278-12470/com.udai.aadharloan.kredit.finance.pmscheme E/libc: Access denied finding property "vendor.debug.trace.perf"
2020-11-22 01:26:48.844 12278-12278/com.udai.aadharloan.kredit.finance.pmscheme E/HomeActivity: ===== loggin impression
2020-11-22 01:26:58.141 12278-12314/com.udai.aadharloan.kredit.finance.pmscheme E/BufferQueueProducer: [unnamed-12278-7] setMaxDequeuedBufferCount: 2 dequeued buffers would exceed the maxBufferCount (2) (maxAcquired 1 async 0 mDequeuedBufferCannotBlock 0)
2020-11-22 01:26:58.141 12278-12314/com.udai.aadharloan.kredit.finance.pmscheme E/Surface: IGraphicBufferProducer::setBufferCount(3) returned Invalid argument
2020-11-22 01:26:58.146 12278-12314/com.udai.aadharloan.kredit.finance.pmscheme E/BufferQueueProducer: [unnamed-12278-8] setMaxDequeuedBufferCount: 2 dequeued buffers would exceed the maxBufferCount (2) (maxAcquired 1 async 0 mDequeuedBufferCannotBlock 0)
2020-11-22 01:26:58.146 12278-12314/com.udai.aadharloan.kredit.finance.pmscheme E/Surface: IGraphicBufferProducer::setBufferCount(3) returned Invalid argument
2020-11-22 01:26:58.151 12278-12314/com.udai.aadharloan.kredit.finance.pmscheme E/BufferQueueProducer: [unnamed-12278-9] setMaxDequeuedBufferCount: 2 dequeued buffers would exceed the maxBufferCount (2) (maxAcquired 1 async 0 mDequeuedBufferCannotBlock 0)
2020-11-22 01:26:58.151 12278-12314/com.udai.aadharloan.kredit.finance.pmscheme E/Surface: IGraphicBufferProducer::setBufferCount(3) returned Invalid argument
2020-11-22 01:27:50.611 12278-12278/com.udai.aadharloan.kredit.finance.pmscheme E/HomeActivity: ===== Ad dismissed.
Here else
part run then new activity open. Then automatically run AdListener
that in If
part.(like:onAdLoaded, onLoggingImpression,onInterstitialDismissed)
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn1Home:
if (interstitialAd.isAdLoaded()) {
Log.e(TAG, "===== btn 1: if part running");
interstitialAd=new InterstitialAd(this,"166868475011030_166000348414076");
interstitialAdListener=new InterstitialAdListener(){
@Override public void onInterstitialDisplayed(Ad ad){}
@Override public void onInterstitialDismissed(Ad ad){
Log.e(TAG, "===== Ad dismissed.");
Intent intent1btn=new Intent(HomeActivity.this,page1activity.class);
startActivity(intent1btn);}
@Override public void onError(Ad ad,AdError adError){}
@Override public void onAdLoaded(Ad ad){
Log.e(TAG, "===== AdListener : Ad loaded and then show.");
interstitialAd.show();}
@Override public void onAdClicked(Ad ad){}
@Override public void onLoggingImpression(Ad ad){Log.e(TAG, "===== loggin impression");}};
// For auto play video ads, it's recommended to load the ad
// at least 30 seconds before it is shown
interstitialAd.loadAd(interstitialAd.buildLoadAdConfig().withAdListener(interstitialAdListener).build());
}else {
Log.e(TAG, "===== BTN 1 ELSE PART");
if (!interstitialAd.isAdLoaded()) {
interstitialAd.loadAd();
Intent intent1btn = new Intent(HomeActivity.this, page1activity.class);
startActivity(intent1btn);
}
}
break;
.........
How can i solve this facebook interstitial ad problem?
I solve this problem:
Do not call
interstitialAd.show()
inonAdLoaded(Ad ad)
.It call just after before
AdListener
mean beforeLog.e(TAG, "===== btn 1: if part running")