Using interstitials from Admob in a Libgdx game for Android, it's slow when dismissing it

喜你入骨 提交于 2019-12-24 14:18:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!