I have an Android app that worked great, before I've added admob activity. I'm closing my app with killing process (calling System.exit(0)). I know that this is the worst solution of finishing the app. I'm working with OpenGL states and libgdx framefork, so I can't fixed all memory leak that appear when I'm calling standard android finish() function.
So here's the problem:
My app works normally several times. I close and start it again and again. All works fine, but suddenly admob view doesn't appear and when I'm trying to close, it freezes. The sound works, last screen shows itself, but touching not working.
When I'm killing the process by task manager, the music still playing. Even when I completely remove the app, music still playing, so activity still working. It stops only when I reboot my phone.
Without admob all works fine. I also trying destroy adView before closing, without result.
Here is my main activity:
public class ControllerActivity extends AndroidApplication{
private AdView adView;
RelativeLayout layout;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = true;
cfg.useCompass = false;
cfg.useAccelerometer = false;
layout = new RelativeLayout(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
View gameView = initializeForView(Controller.getInstance(), cfg);
adView = new AdView(this, AdSize.BANNER, "MYID");
AdRequest adRequest=new AdRequest();
adView.loadAd(adRequest);
layout.addView(gameView);
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layout.addView(adView, adParams);
setContentView(layout);
}
@Override
public void onDestroy() {
if (adView!=null) {
adView.stopLoading();
adView.destroy();
}
System.exit(0);
super.onDestroy();
}
}
Have your any ideas, how to completely kill this process?