I just made game like ironpants, I'm trying to put interstitial ads when the game over.
but right now, when I developed this game, the interstitial ads always show in the middle of the game. I think it'll be annoying for users.
The interstitial ads only show after 5x game over.
I think it is because I only have one screen for this game MainGameView.java. so when user dead after play the game, the ads don't have time to load, and the it will load in the middle of the game? is it againts admob TOS?
here's the code to show admob interstitial ads when the game was over.
the methods to initialize the interstitial ads
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initialiseAccelerometer();
// Create the interstitial
interstitial = new InterstitialAd(this, getResources().getString(R.string.InterstitialAd_unit_id));
}
public void openAd() {
runOnUiThread(new Runnable() {
public void run() {
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
interstitial.setAdListener(new AdListener() {
@Override
public void onReceiveAd(Ad arg0) {
if (interstitial.isReady()) {
interstitial.show();
}
}
@Override
public void onPresentScreen(Ad arg0) {
}
@Override
public void onLeaveApplication(Ad arg0) {
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
}
@Override
public void onDismissScreen(Ad arg0) {
}
});
}
});
}and I call openAd() method when the game was over
public synchronized void GameOver() {
if (adounter >= this.getResources().getInteger(R.integer.add_shows_every_X_gameovers)) {
openAd();
adounter = 0;
}
adounter++;
}can you guys give me some advice how to handle situation like this?
thank you very much and sorry for my bad English.
|
||||||