AdMob サイト (こちら:https://developers.google.com/mobile-ads-sdk/docs/?hl=en) の手順に従っていますが、まだ広告を機能させることができません。しかし、何も問題はないようです。
これが私のレイアウトです:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:soundEffectsEnabled="true"
android:id="@+id/mainLayout"
android:background="@drawable/bg_maple"
>
[...]
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adUnitId="my real unit id from admob"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, my real device id"
ads:loadAdOnCreate="true"/>
[...]
そして私の活動では:
public class Banner extends Activity {
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adView
adView = new AdView(this, AdSize.BANNER, "my real unit id from admob");
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.mainLayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
adRequest.addTestDevice("Here I have my device ID");
}
@Override
public void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
助けていただければ幸いです。私は立ち往生しており、現時点では何が問題なのかわかりません。
注: ユニット ID とデバイス ID の両方がコードに正しく追加されています。