xamarin - Admob lag only on Android -
i having issue admob causing high amount of lag when ad loading. have admob setup both android , ios, , problem occurs on android. running on older iphones, there little no lag, whereas high end android phones (nexus 6p lg g4) having lag. use xamarin studio , monogame's framework build apps. i've tried threading ad separately.
i've searched on answer, , know found android heap limit/size? problem? game lags when it's not recieving ad, believe ad's animation may problem. thank in advance help!
here code:
protected override void oncreate(bundle bundle) { base.oncreate(bundle); // create our opengl view, , display // !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(); }
a possible solution can use interstitial ads in pause screen or when player finished level (for example). banner shouldn't create lag or problem. maybe can try load ad before game start (in loading screen example) , show after. here there template interstitial ads , banner ads included. every line commented it's veri easy understand: https://github.com/odle98/monogameandroid-baseapp-ads project ready compiled, stuff altrady added.
hope might useful :)
Comments
Post a Comment