"I bought a book called ""Android 2D Game Made by AndEngine"" and studied it."
At the end of the day, perhaps because the information in the book is old, I was at a loss because I couldn't display the advertisement even if I followed the book.
As the book says, AdMob itself is up to date.There are no errors.
However, loadAd(); is forced to terminate.
How do you view AdMob ads?Please tell me the sauce.
Sorry for the bold and brazen question.
"I think it's not one question, but I thought it would be better to ask ""What's wrong with this kind of source?"" than to ask ""This is how you can do it!""" and I thought that I couldn't convey enough information due to my lack of knowledge."
Thank you for your cooperation.
android admob
I don't have a book called Android 2D Gaming with AndEngine, so I'm going to use a typical AdMob installation method.
1 Add GooglePlayServices to dependencies
compile'com.google.android.gms:play-services:6.5.+'
2 Add the following entry to the AndroidManifest.xml child
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
3 Create an AdView instance and add it to View per Activity onCreate()
mAdView=newAdView(this);
mAdView.setAdUnitId(Constants.ADMOB_ID);
mAdView.setAdSize (AdSize.BANNER);
AdRequest adRequest=new AdRequest.Builder()
.addTestDevice ("ID for Test Device")
.build();
mAdView.loadAd(adRequest);
FrameLayout adLayout=(FrameLayout) findViewById (R.id.layout_ad);
adLayout.addView(mAdView);
Call each method with 4 onResume()/onPause()/onDestroy()
@Override
protected void onResume() {
super.onResume();
mAdView.resume();
}
@ Override
protected void onPause() {
super.onPause();
mAdView.pause();
}
@ Override
protected void onDestroy() {
super.onDestroy();
mAdView.destroy();
}
I'm studying too.I was worried that it didn't show up in the same way, but I managed to do the following.
Specifically, add the onCreate method to MainActivity.
That book is designated as onCreateScene.
public class MainActivity extensions MultiSceneActivity{
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adView=(AdView)this.findViewById(R.id.adView);
AdRequest adRequest=new AdRequest.Builder()
.addTestDevice (AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice ("xxxxxxxx")
.build();
adView.loadAd(adRequest);
}
}
Has it already been resolved?
© 2024 OneMinuteCode. All rights reserved.