I am having an issue with Admob causing a high amount of lag when the ad is loading. I have Admob setup for both android and ios, and the problem only occurs on android. Even running on older iphones, there is little to no lag, whereas high end android phones (nexus 6p an lg g4) are having lag. I use Xamarin Studio and Monogame's framework to build my apps. I've also tried threading the ad separately.
I've searched all over for an answer, and I know I found something about the android heap limit/size? Could this be a problem? Sometimes my game even lags when it's not recieving the ad, but I believe the ad's animation may be a problem. Thank you in advance for all help!
Here is my code:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Create our OpenGL view, and display it
// !IMPORTANT!
var g = new Game1();
//SetContentView((View)g.Services.GetService(typeof(View)));
//createAds((View)g.Services.GetService(typeof(View)));
createAds(g.Services.GetService<View>());
// !IMPORTANT!
g.Run();
}
private void createAds(View window)
{
var frameLayout = new FrameLayout(this);
var linearLayout = new LinearLayout(this);
frameLayout.AddView(window);
adView = new AdView(this);
adView.AdUnitId = AD_UNIT_ID;
adView.AdSize = AdSize.SmartBanner;
adView.SetBackgroundColor(Android.Graphics.Color.Transparent);
linearLayout.AddView(adView);
frameLayout.AddView(linearLayout);
SetContentView(frameLayout);
var myThread = new Thread(new ThreadStart(() =>
{
var requestbuilder = new AdRequest.Builder();
RunOnUiThread(() =>
{
adView.LoadAd(requestbuilder.Build());
});
}));
myThread.Priority = (System.Threading.ThreadPriority)(Android.OS.ThreadPriority)(-20);
myThread.Start();
}