处理程序没有按照指定的每分钟执行 运行 方法?
Handler not executing run method as per minute specify?
我在 1 分钟后显示插页式广告,我为此使用了处理程序
它可以正常工作几分钟,然后在 1 分钟前显示广告,5 秒 10 秒后快速完成显示
如何解决这个问题。
这是我的代码
准备广告();
ScheduledExecutorService scheduler =
Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG"," Interstitial not loaded");
}
prepareAd();
}
});
}
}, 60, 60, TimeUnit.SECONDS);
public void prepareAd(){
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
这违反了 AdMob 政策,如果您这样做,您的帐户将被暂停。
如果您想了解有关如何在您的应用程序中放置 admob 广告的更多信息。我推荐你访问这个网站。
http://www.elegantespace.com/how-to-load-interstitial-ad-at-regular-interval-of-time/
我在 1 分钟后显示插页式广告,我为此使用了处理程序 它可以正常工作几分钟,然后在 1 分钟前显示广告,5 秒 10 秒后快速完成显示 如何解决这个问题。
这是我的代码
准备广告();
ScheduledExecutorService scheduler =
Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG"," Interstitial not loaded");
}
prepareAd();
}
});
}
}, 60, 60, TimeUnit.SECONDS);
public void prepareAd(){
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
这违反了 AdMob 政策,如果您这样做,您的帐户将被暂停。
如果您想了解有关如何在您的应用程序中放置 admob 广告的更多信息。我推荐你访问这个网站。
http://www.elegantespace.com/how-to-load-interstitial-ad-at-regular-interval-of-time/