• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Admob Ads

I was wondering if somebody knew a link to a good tutorial for adding admob ads to your android application. I have checked out several tutorial and followed the steps...including the instructions from admob and my app just force closes now and I do not know where my errors are.
 
Android - Admob For Developers has quite straightforward instructions. It's missing one step that the LunarLander has. Not sure if it's needed, but it might aid debugging at least. The LunarLander example set an AdListener, which logs when ads are fetched, or when they failed to be fetch.

It's also straightforward to do. Just make user Activity class implement com.admob.android.ads.AdListener, and then implement the following methods in your Activity class:

Code:
    public void onFailedToReceiveAd(AdView adView)
    {
        Log.d("AdListener", "onFailedToReceiveAd");
    }

    public void onFailedToReceiveRefreshedAd(AdView adView)
    {
        Log.d("AdListener", "onFailedToReceiveRefreshedAd");
    }

    public void onReceiveAd(AdView adView)
    {
        Log.d("AdListener", "onReceiveAd");
    }

    public void onReceiveRefreshedAd(AdView adView)
    {
        Log.d("AdListener", "onReceiveRefreshedAd");
    }

You also need to set the listener in your Activity's onCreate:

Code:
    AdView ad = (AdView) findViewById(R.id.ad);
    ad.setAdListener(this);

If you still can't get it to work, please post logcat output, which should include the traceback. It would also be very helpful to see your code, at least the parts that deals with AdMob.
 
I keep hearing about this LunarLander program with admob in it but I cant find it anywhere. Anyone have a link to it? When I use the link in the SDK I get 404.
 
Alienmark67, you get the Lunar Lander code when you sign up to admob. But I think you need to have an application on the Market before you can access it.

meskiukas, thanks for your advice. Unfortunately I still can't get my application to show adverts. It's called LGF Card Counter Lite on the app market. I could send you the source code if that helps.

tp_technologies, I still can't find a good tutorial for admob. The only tutorial is a set of steps provided by Admob, but as meskiukas has pointed out, it's mising out some vital steps.

Cheers
 
I've added the code

AdView ad = (AdView) findViewById(R.id.ad);
ad.setAdListener(this);

Unfortunately I'm now getting a NullPointerException on the 2nd line above. Looks like ad is not being set :(
 
And since you use this as parameter i guess you have implemented the listener in your class?
 
Back
Top Bottom