[Q] Libgdx and Admob

Hello everybody,

I am a new developer and started with Libgdx to make a simple game (Flappy Bird) an understand everything.
My English is not the best but I could understand this tutorial () and make my "own" Flappy Bird.
To complete the tutorial I wanted to show some ads in the app but it didn't work. I used the ads from admob.
Can someone explain me how I can show ads? I think libgdx is the problem but I don't know what I did wrong.

I found this code but it doesn't work and I am getting a few errors: (Is ist correct and am I right if I do in the Android folder a new class
called BannerExample and put this code in it?

Quote:

import com.google.ads.*;

public class BannerExample 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_AD_UNIT_ID);

// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout)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());
}

@Override
public void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}

PS: Sorry for my bad English!

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by barton.katlynn
18 minutes ago
Last post by jevon.mitchell
2 hours ago
Last post by xprohaska
37 minutes ago
Last post by donny46
51 minutes ago
Last post by gibson.rudolph
2 hours ago
Last post by virginia75
3 hours ago
Last post by ruecker.grady
3 hours ago
Last post by jennyfer47
2 hours ago
Last post by einar98
1 hour ago
Last post by hwillms
3 hours ago
Last post by yturner
2 hours ago
Last post by jeffertz
17 minutes ago