android - Libgdx final stage of adding admob to game -
i had finished game , wanted add admob ads game.
i followed instructions in libgdx in admob
and it's working well, , ads shown properly, wanna sure did , version of adomb proper , know if ready signed , uploaded play store :
here code in androidluncher:
public class androidlauncher extends androidapplication implements adhandler { private static final string tag="androidlauncher"; protected adview adview; private final int show_ads=1; private final int hide_ads=0; handler handler=new handler(){ @override public void handlemessage(message msg) { switch (msg.what){ case show_ads: adview.setvisibility(view.visible); break; case hide_ads: adview.setvisibility(view.gone); break; } } }; @override protected void oncreate (bundle savedinstancestate) { super.oncreate(savedinstancestate); relativelayout layout=new relativelayout(this); androidapplicationconfiguration config = new androidapplicationconfiguration(); view gameview= initializeforview(new fruits(this),config); layout.addview(gameview); adview=new adview(this); adview.setadlistener(new adlistener() { @override public void onadloaded() { log.i(tag, "ad loaded"); } }); adview.setadsize(adsize.smart_banner); adview.setadunitid("ca-app-pub-7056408444444289676685175896"); adrequest.builder builder=new adrequest.builder(); relativelayout.layoutparams adparams=new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content,relativelayout.layoutparams.wrap_content); adview.loadad(builder.build()); layout.addview(adview, adparams); setcontentview(layout); //initialize(new fruits(), config); } @override public void showads(boolean show) { handler.sendemptymessage(show ?show_ads:hide_ads); } }
and manifest.xml file:
<uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_network_state"/> <uses-sdk android:minsdkversion="9" android:targetsdkversion="23" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/gdxtheme" > <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> <activity android:name="com.mygdx.game.androidlauncher" android:label="@string/app_name" android:screenorientation="landscape" android:configchanges="keyboard|keyboardhidden|orientation|screensize"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="com.google.android.gms.ads.adactivity" android:configchanges="keyboard|keyboardhidden|orientation|screenlayout|uimode|screensize|smallestscreensize"/> </application> </manifest>
and here build.grade:
ext { appname = "fruits eater" gdxversion = '1.7.2' robovmversion = '1.12.0' box2dlightsversion = '1.4' ashleyversion = '1.7.0' aiversion = '1.7.0' admobversion='9.2.0' } dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-android:$gdxversion" natives "com.badlogicgames.gdx:gdx-platform:$gdxversion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-platform:$gdxversion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxversion:natives-x86" compile "com.badlogicgames.gdx:gdx-box2d:$gdxversion" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxversion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxversion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxversion:natives-x86" compile "com.google.android.gms:play-services-ads:$admobversion" }
and want know if need add google.service.json , or can publish game ads without need of google.service.json file
you don't need add file show ad in app.that file needed other more useful purposes...such in database,etc...
Comments
Post a Comment