我用InterstitialAd开发了一个简单的Kannada填字游戏应用程序,并与朋友分享以获取反馈。最初,我设置条件,以便朋友/其他任何人直到2019年4月1日才能看到广告,因此我在Circle-Progress-View's OnProgressChangedListener中添加了逻辑。在调试时,我在其他时间戳上测试了相同的逻辑,并且按预期运行,但是一些朋友正在从playstore中为发布版本展示广告。
正如在下面的代码中看到的那样,这只是简单的条件,我使showInterstitial()仅从OnProgressChangedListener调用,没有其他地方可以使用,最重要的是System.currentTimeMillis()
与> = 01-apr-2019进行了检查。 />
BTW Interstitial frequency capping
在AdMob的应用设置中被禁用。
private int MIN_AD_INTERVAL_IN_SECONDS = 480;
private long START_AD = 1554076800;
@Override
protected void onCreate(Bundle savedInstanceState) {
// other codes pre-required codes
MobileAds.initialize(this,"ca-app-pub-MYAppID~Here");
interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId("ca-app-pub-MyUnit/IdHere");
// other codes like initGridViews, initProgressView, initListeners etc.
}
CircleProgressView.OnProgressChangedListener() {
@Override
public void onProgressChanged(float value) {
Log.d(TAG, "Progress Changed: " + value);
long fullMsecs = System.currentTimeMillis();
Log.d(TAG, "onProgressChanged: curre epoc"+fullMsecs);
if(ad_last_loaded==0){
//ad loading first time in this session. update global variable accordingly
ad_last_loaded=SystemClock.elapsedRealtime();
}
long ad_interval = SystemClock.elapsedRealtime()-ad_last_loaded;
Log.d("elog", "e"+fullMsecs);//^
if((ad_interval/1000)>MIN_AD_INTERVAL_IN_SECONDS && value>50 && fullMsecs>=START_AD)
{
// if progress>50 i.e if user finished 50% of level.
// and time elapsed is 8m since last ad
// and current system time is greater than 1554076800 ie. 01-apr-2019
Log.d(TAG, "Progress Changed: ad triggred" + value);
showInterstitial();
}
}
});
private void showInterstitial() {
// Show the ad if it's ready. Otherwise reload again.
if (interstitialAd != null && interstitialAd.isLoaded()) {
//Log.d(TAG, "showInterstitial: ");
interstitialAd.show();
} else {
//Log.d(TAG, "showInterstitial: Ad did not load");
reloadAdAgain();
}
}
private void reloadAdAgain() {
// Request a new ad if one isn't already loaded
if (!interstitialAd.isLoading() && !interstitialAd.isLoaded()) {
AdRequest adRequest = new AdRequest.Builder().build();
interstitialAd.loadAd(adRequest);
}
}
^我让此登录发行版检查当前时间。没有其他日志记录在发布版本中,并且故意在此处添加了代码中。
PS:我可以在这里共享playstore应用程序链接吗?