问题
I've been using interstitials from Admob with my libgdx game for Android and my problem is that when I dismiss it after it was shown, it takes quite some time to give the control back to my game (around 4-5 seconds, which is not good at all). I don't know why it does that. Also, when I just leave my game (pressing the Home button) and then come back to it, it also takes around the same time. Maybe it has something to do with the opengl context loss..
回答1:
Run the ad call on a separate UI thread and display add only if and only if internet connection is there in phone
void callAd(){
runOnUiThread(new Runnable() {
@Override
public void run() {
//your add call
}
});
}
回答2:
Thats Context Loss indeed, the Textures are being reloaded, thus taking some time to resume.
But how come when I play "Doodle jump" on my phone (with the same internet connection), when I die, an interstitial Ad appears but when I dismiss it, i go right back to the game without having to wait at all..
DoodleJump doesn't use OpenGL, so it doesn't have this problem. Also, its graphics are too simple and light it wouldn't take too much time to reload if it did anyways :)
来源:https://stackoverflow.com/questions/19981956/using-interstitials-from-admob-in-a-libgdx-game-for-android-its-slow-when-dism