Reputation: 1279
So I made a game that I'm trying to add ads to but I'm not using any XML
. I found two examples that say they should work after extensive research and many hours of looking. How ever even when I try implementing that code I still get errors and am at a loss.
I've searched through stack overflow and many other sites and I am at a loss. Ive tried implementing this several different ways and I'm not sure if I'm not including ti right or what.
Here are the two remaining errors I'm getting:
The Constructor is not working for the AdView
class the way its described in the tutorial and I'm not sure how to fix that.
and the AdRequest() function says its implemented as private and even when i try to use the AdRequest().Builder().build(); it still gives the same error.
I have no xml in my code and am using a class that extends SurfaceView for the entire game, and i am using AdMob ads. How do i do this with out xml?
Upvotes: 0
Views: 140
Reputation: 801
Here is how I load my ads. Hope it helps.
admobAdView = new com.google.android.gms.ads.AdView(getActivity());
admobAdView.setAdSize(AdSize.SMART_BANNER);
admobAdView.setAdUnitId("ca-app-pub-###########/#######");
adViewContainer = (ViewGroup) getView().findViewById(R.id.ad_view_group);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("#################")
.build();
admobAdView.loadAd(adRequest);
Upvotes: 1