1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Admob Ads


Last Updated:

  1. tp_technologies

    tp_technologies Well-Known Member This Topic's Starter

    Joined:
    Apr 26, 2010
    Messages:
    65
    Likes Received:
    5
    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.
     

    Advertisement
  2. meskiukas

    meskiukas Member

    Joined:
    Aug 20, 2010
    Messages:
    13
    Likes Received:
    1
    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 (Text):
    1.  
    2.     public void onFailedToReceiveAd(AdView adView)
    3.     {
    4.         Log.d("AdListener", "onFailedToReceiveAd");
    5.     }
    6.  
    7.     public void onFailedToReceiveRefreshedAd(AdView adView)
    8.     {
    9.         Log.d("AdListener", "onFailedToReceiveRefreshedAd");
    10.     }
    11.  
    12.     public void onReceiveAd(AdView adView)
    13.     {
    14.         Log.d("AdListener", "onReceiveAd");
    15.     }
    16.  
    17.     public void onReceiveRefreshedAd(AdView adView)
    18.     {
    19.         Log.d("AdListener", "onReceiveRefreshedAd");
    20.     }
    21.  
    You also need to set the listener in your Activity's onCreate:

    Code (Text):
    1.        
    2.     AdView ad = (AdView) findViewById(R.id.ad);
    3.     ad.setAdListener(this);
    4.  
    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.
     
  3. Alienmark67

    Alienmark67 New Member

    Joined:
    Nov 8, 2010
    Messages:
    1
    Likes Received:
    0
    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.
     
  4. leefisher

    leefisher Member

    Joined:
    Jun 19, 2010
    Messages:
    6
    Likes Received:
    0
    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
     
  5. leefisher

    leefisher Member

    Joined:
    Jun 19, 2010
    Messages:
    6
    Likes Received:
    0
    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 :(
     
  6. miXer

    miXer Well-Known Member

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    And since you use this as parameter i guess you have implemented the listener in your class?
     
  7. leefisher

    leefisher Member

    Joined:
    Jun 19, 2010
    Messages:
    6
    Likes Received:
    0
    I've added "implements AdListener" to the class declaration if that's what you mean.
     

Share This Page

Loading...