2

I'm trying to integrate an admob banner into my Android game. I have a somewhat special case as my game screen is handled by a custom class that extends SurfaceView. I implemented the code from this page: http://rx-games.com/admob-adverts-on-surfaceview-no-xml-tutorial/ and it all compiles and runs without error.

Problem is, there are no ads and there is no banner when I run it on either my real device or my emulator. I feel like I somehow need to implement something like: "AdManager.setTestDevices( new String[] { AdManager.TEST_EMULATOR } );" like the page says, but the new google.ads package doesn't contatin an AdManager class.

Anyone have any experience with this? I need to know if the ad banner works or not before I send out this next game update. I can provide any code you'd like to see, but it is all exactly the same as in the above link. Let me know, thanks

2 Answers 2

3

I found that the problem was in the way the example called the ads. Instead of using their method showAd(), I needed to use this code right after my call to setContentView():

 AdRequest request = new AdRequest(); request.setTesting(true); adView.loadAd(request); 

That gets it to work. Just remember to take out the testing line when publishing.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this code. It makes requests but it is not displayed on the screen.
Yeah don't use their showAd() method - see my answer below. Also, it takes about a minute for the sample ad to show up, its not instantaneous
0

i had the same problem, my custom surface view means ads dont show.

in you main.xml it looks something like this:

LinearLayout (Fill, Parent, Fill Parent) - Customs Surface View (Fill Fill)

add a new layout to hold a top banner ad:

LinearLayout (Fill, Parent, Fill Parent) - LinearLayoutAd (Wrap Vertical, Fill Horizontal) - Customs Surface View (Fill Fill)

now put your ad in the linearlayoutad. This might affect any screen metrics you have as your custom surface is now smaller.

1 Comment

Not sure I follow.. I don't have a main.xml file, my entire surface view is layed out in a java class.. I think though the problem might be more complicated than I originally thought. I started a bare essentials sample admob app to try and figure some of this stuff out, but I'm having some new problems with it. Check out this thread: stackoverflow.com/questions/6089130/…. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.