1. Download our Official Android App: Forums for Android!

Apps Admob Ads

Discussion in 'Android Development' started by tp_technologies, Aug 27, 2010.

  1. tp_technologies

    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    65
    Joined:
    Apr 26, 2010

    Apr 26, 2010
    65
    5
    16
    Canada
    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 Newbie
    Rank:
    None
    Points:
    36
    Posts:
    13
    Joined:
    Aug 20, 2010

    Aug 20, 2010
    13
    1
    36
    Programmer
    Sweden
    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Nov 8, 2010

    Nov 8, 2010
    1
    0
    5
    Programmer
    Louisville, Kentucky
    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Jun 19, 2010

    Jun 19, 2010
    6
    0
    5
    Northeast England
    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Jun 19, 2010

    Jun 19, 2010
    6
    0
    5
    Northeast England
    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 Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    313
    Joined:
    Aug 12, 2010

    Aug 12, 2010
    313
    51
    53
    Norway
    And since you use this as parameter i guess you have implemented the listener in your class?
     
  7. leefisher

    leefisher Lurker
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Jun 19, 2010

    Jun 19, 2010
    6
    0
    5
    Northeast England
    I've added "implements AdListener" to the class declaration if that's what you mean.
     

Share This Page

Loading...