如何在 X 点击后显示 InterAd?
Posted
技术标签:
【中文标题】如何在 X 点击后显示 InterAd?【英文标题】:How Can Show InterAd After X Clicks? 【发布时间】:2021-09-27 15:50:37 【问题描述】:如何在此代码 java 中单击 2 次按钮后显示插页式广告? "持续 SDK Admob 20.2.0"
btn1.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Log.d(TAG,"Button 1 Clicked");
if (mInterstitialAd != null)
save_id(btn1.getId());
mInterstitialAd.show(main_activity.this);
else
Log.d("TAG", "The interstitial ad wasn't ready yet");
Intent intent = new Intent(main_activity.this, getstarted.class);
startActivity(intent);
);
【问题讨论】:
【参考方案1】:您可以存储像clickCount
这样的变量,并且每次都存储它的even value
即。 modulo by 2 == 0
你可以展示广告吗?
int clickCount = 0
;
btn1.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Log.d(TAG,"Button 1 Clicked");
clickCount++;
if (mInterstitialAd != null && (clickCount % 2 == 0))
clickCount = 0;
save_id(btn1.getId());
mInterstitialAd.show(main_activity.this);
else
Log.d("TAG", "The interstitial ad wasn't ready yet or the button was only clicked once");
Intent intent = new Intent(main_activity.this, getstarted.class);
startActivity(intent);
);
【讨论】:
如果有效,请考虑接受答案作为正确答案!以上是关于如何在 X 点击后显示 InterAd?的主要内容,如果未能解决你的问题,请参考以下文章