0
我檢查其他話題有關SOF,並尋找一些新的知識。如何刪除延遲展示在此代碼AdMob Intersitial廣告刪除延遲
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if (getResources().getString(R.string.InterstitialAd_unit_id).length() > 0) {
// Create the interstitial
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(getResources().getString(R.string.InterstitialAd_unit_id));
// Create ad request.
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
}
//initialise banner ad
this.BANNER_AD_UNIT_ID = getResources().getString(R.string.BannerAd_unit_id);
showBanner();
}
public void openAd() {
if (getResources().getString(R.string.InterstitialAd_unit_id).length() > 0) {
runOnUiThread(new Runnable() {
public void run() {
if (!interstitial.isLoaded()) {
interstitial.loadAd(adRequest);
}
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
interstitial.show();
}
});
}
});
}
}
這裏的淵源發佈AdMob聯播間質性廣告:How to make Admob interstitial show without delay?
我m newbie and just learning programming, that
就是爲什麼我真的問例如在此代碼:)
編輯: 這就是openAd被稱爲的方式
public synchronized void GameOver() {
if (lives_left > 0) {
//success! - game passed - save score
ScoreManager.save_localscore_simple(score_times[currentLevel], "" + currentLevel, false);
if (Level_Buttons.length >= currentLevel + 1)
ScoreManager.save_localscore_simple(unlocked, "unlock" + (currentLevel + 1));
if (sound_success != 0 && !sound_muted)
sp.play(sound_success, 1, 1, 0, 0, 1);
//intersitial ad
ad_counter++;
if (ad_counter >= getResources().getInteger(R.integer.ad_shows_every_X_gameovers)) {
openAd();
ad_counter = 0;
}
} else {
//game not passed
if (sound_gameover != 0 && !sound_muted)
sp.play(sound_gameover, 1, 1, 0, 0, 1);
}
//open interstitial ad
ad_counter++;
if (ad_counter >= getResources().getInteger(R.integer.ad_shows_every_X_gameovers)) {
openAd();
ad_counter = 0;
}
哦,威廉,我希望你會回答我的問題,你在這裏:)謝謝!但是你能否解釋我一點,因爲我正在學習,而且我很困惑。我必須如何更改我的代碼才能工作?我嘗試了所有方法,但每次出現錯誤。 – Karnak 2015-02-11 23:32:30