Android : Admob Interstitial is keeping activity on background (OpenGL)

on Sunday, October 12, 2014


For now I can load adds and show them on natural breaking points in my game. Just how it should I think. Because I'm using OpenGL the adds will load in the GL class and not in the one which is implementing this GL class.


The case for now is that when going from let's say the LevelOverview -> Level 1, the add loads when Level 1 starts and will show when I press the button to go back to the levelOverview. When I start level 1 again, the process starts again.


The problem is that the activity (level 1) stays in the background each time. So after 4 switches between LevelOverview -> Level 1 -> levelOverview I have 4 activities in the background of level 1. This will cause an OOM error after a while.


I tried to everything to close the activity, for now I have it like this



Intent ia = new Intent(getApplicationContext(), LevelOverview.class);
finish();
super.onStop();
onStop();
texture1.dispose();
texture2.dispose();
startActivity(ia);
displayInterstitial();
interstitial=null;


I even tried to dispose my textures to save space. However this is not needed I think.


The memomory analyser shows that Admob is keeping references to all of these level 1 activities. However I can't get rid of these references. (I tried to nullify the interstitial in several ways)


How can I delete the admob references so the GC can do his work on my old activities?


0 comments:

Post a Comment