Wednesday, 15 September 2010

admob - Android: AdView not getting displayed, though Log shows Ad is loaded -



admob - Android: AdView not getting displayed, though Log shows Ad is loaded -

i working cocos2dx js 3.0 , trying implement admob straight in android without going through cocos2dx calls.

created adunit , implemented adview follows:

adrequest request = new adrequest.builder() .addtestdevice(adrequest.device_id_emulator) .addtestdevice("ac2dfffafb44fe1ebc80f6b40559ab14") .build(); adview adview = new adview(appactivity.this); adview.setadsize(adsize.banner); adview.setadunitid("ca-app-pub-xyz/xyz"); adview.loadad(request); @suppresswarnings("deprecation") viewgroup.layoutparams ad_layout_params = new viewgroup.layoutparams(viewgroup.layoutparams.fill_parent, viewgroup.layoutparams.wrap_content); adview.setlayoutparams(ad_layout_params); mframelayout.addview(adview); //here `mframelayout` core `relativelayout` contains glview's run cocos engine.

in logcat, getting following, advertisement not displayed !!

starting advertisement request. js: [some js logs] advertisement finished loading. scheduling advertisement refresh 60000 milliseconds now. advertisement not visible. not refreshing ad. scheduling advertisement refresh 60000 milliseconds now. advertisement not visible. not refreshing ad. scheduling advertisement refresh 60000 milliseconds now. advertisement not visible. not refreshing ad. [repeating]

i guess, admob integration done right, issue adding adview right parent view or issue setting position of adview.

as per thread (move adview bottom, cocos2dx activity), changed mframelayout in cocos2dxactivity relativelayout

any help highly appreciated !!

resolved issue... :-)

the glsurfaceview getting returned oncreateview added mframelayout in superclass cocos2dxactivity, hence taking on adview...

hence,

assigned tag(999) adview in here, and in super class cocos2dxactivity, once glsurfaceview added mframelayout the kid tag 999 (our adview) brought front..

code:

oncreateview of our activity:

adrequest request = new adrequest.builder() .build(); adview adview = new adview(appactivity.this); adview.setadsize(adsize.banner); adview.setadunitid("ca-app-pub-xyz"); adview.setid(999); adview.loadad(request); @suppresswarnings("deprecation") relativelayout.layoutparams params = new relativelayout.layoutparams(viewgroup.layoutparams.match_parent, viewgroup.layoutparams.wrap_content); params.addrule(relativelayout.align_parent_top, relativelayout.true); adview.setlayoutparams(params); mframelayout.addview(adview);

in frameworks/js-bindings/cocos2d-x/cocos/platform/android/java/src/org/cocos2dx/lib/cocos2dxactivity.java:190 end of init function,

mframelayout.bringchildtofront(mframelayout.findviewbyid(999));

android admob cocos2d-x cocos2d-x-3.0

No comments:

Post a Comment