Ich hatte mein Spiel beendet und wollte Admob-Anzeigen zum Spiel hinzufügen.Libgdx letzte Phase des Hinzufügens von Admob zum Spiel
folgte ich alle Anweisungen in Libgdx in admob
und es funktioniert sehr gut, und die Anzeigen sind richtig gezeigt, ich möchte nur sicher sein, dass ich alles gut gemacht und die Version des adomb richtig ist und wissen, ob die ist bereit, in den Play Store unterzeichnet und hochgeladen werden:
hier ist der Code in der 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);
}
}
und dies ist die Datei manifest.xml:
<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>
und hier ist die 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"
}
Und ich möchte wissen, ob benötige ich google.service.json hinzuzufügen, oder kann ich mein Spiel mit Anzeigen, ohne die Notwendigkeit von Google veröffentlichen .service.json