A lot of it was in this forum somewhere.
there are two things that need to be done (after you make your admob account)
this goes somewhere in your sketch:
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Window window = getWindow();
- RelativeLayout adsLayout = new RelativeLayout(this);
- RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT);
- // Displays Ads at the bottom of your sketch, use Gravity.TOP to display them at the top
- adsLayout.setGravity(Gravity.BOTTOM);
- AdView adView = new AdView(this, AdSize.BANNER, "YOUR PERSONAL APP ID"); // add your app-id
- adsLayout.addView(adView);
- AdRequest newAdReq = new AdRequest();
- // Remark: uncomment next line for testing your Ads (fake ads)
- //newAdReq.setTesting(true);
- adView.loadAd(newAdReq);
- window.addContentView(adsLayout, lp2);
- }
The next part has to go in your android manafest, and this is just a lot easier in Eclipse.
put it after the automatic activity, and before the </application> tag
- <activity android:name="com.google.ads.AdActivity"
- android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>