Admnob for Android using GoogleAdMobAdsSdk-4.0.4.jar

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

Admnob for Android using GoogleAdMobAdsSdk-4.0.4.jar

Postby lukethor » Sun May 01, 2011 4:15 pm

Here is another way to get the Admob banner working in your application based on the following link The library you need to add to your working is project is
GoogleAdMobAdsSdk-4.0.4.jar found in the previous URL.

public void onCreate(Bundle savedInstanceState) {

// New game view

View gameView = initializeForView( new YourBadLogicGame(), false, new FillResolutionStrategy(), 0);
gameView.setKeepScreenOn(true); // optional
// Create the adView
// Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
// String MY_BANNER_UNIT_ID = "abcde123456"; whatever id you get from AdMob

AdView adView = new AdView(this, AdSize.BANNER, MY_BANNER_UNIT_ID);

FrameLayout layout = new FrameLayout(this); // everything at the top left of the screen

addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

layout.addView(gameView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

layout.addView(adView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

// Initiate a generic request to load it with an ad
AdRequest request = new AdRequest();


Posts: 58
Joined: Sun May 01, 2011 4:00 pm

Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest