I have a game which has ads in it.I eventually found the source of lag is basically because of the adRequest process which takes a long time.
super.onCreate(savedInstanceState){
mainLayout = new LinearLayout(this);
mainLayout.setOrientation(LinearLayout.VERTICAL);
adView = new AdView(this, AdSize.BANNER, "MY_ID");
adView.setVisibility(AdView.VISIBLE);
mainLayout.addView(adView);
adView.loadAd(new AdRequest());
//more codes below
}
I tried to do something like creating a thread which would do some loadAd when there's an adRequest. but that resulting in ads won't show up. So I think the loadAd request must be done in UI Thread. Is there any workaround about this? I still don't understand about how UI Thread works anyway