Showing three admob ads in TabView - android

I need to show one banner ad per one tabview, so I changes the android:id (check below code) and the add is successfully appears in all required tabs. Is it ok or its against Google's Terms of Service. Please tell me if any other way to show the ads
XML
First Layout
<com.google.android.gms.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="#string/admobid"
ads:adSize="SMART_BANNER"/>
Second
<com.google.android.gms.ads.AdView android:id="#+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="#string/admobid"
ads:adSize="SMART_BANNER"/>
Third one
<com.google.android.gms.ads.AdView android:id="#+id/adView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="#string/admobid"
ads:adSize="SMART_BANNER"/>
Java code:
adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("356d67mydeviceid")
.build();
adView.loadAd(adRequest);
adView2 = (AdView)this.findViewById(R.id.adView2);
AdRequest adRequest2 = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("356d67mydeviceid")
.build();
adView2.loadAd(adRequest2);
adView3 = (AdView)this.findViewById(R.id.adView3);
AdRequest adRequest3 = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("356d67mydeviceid")
.build();
adView3.loadAd(adRequest3);
Output
https://lh5.googleusercontent.com/-CPKhDMkAwnU/U5_PtY4U_vI/AAAAAAAAADc/tUeQZTwnBdo/s320/tabview.png

While perhaps not against the spirit of the Admob policy it is probably technically agsint the letter of it. You are probably better off creating a single AdView and positioning it above or below your TabView.

Place your tabview and ad banner into the same layout

Related

Ad Mob ads not showing regularly

I'm testing the ad mobs ads on a real device. Sometimes the ads shows up and sometimes it doesn't shows. I've no idea what the problem is.
While testing on a virtual device I used test ads and they always shows up but now I'am using real ads on a device with real app-id and unit-id.
Below is the code I'm using. Any help would be highly appreciated.
Java Code:
MobileAds.initialize(this,"ca-app-pub-8665656565286300~4683225285");
mAdview = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdview.loadAd(adRequest);
XML:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-8665656565286300/8888341401"
/>

AdMob No Live-Ads appearing

I have made my Application with Android Studio, and now i have a finished app.
I added an AdView to my Application, and used the TestAd-UnitId, and i got test ads. On my Emulator and also on my Mobile Phone. That worked, and i had Test Ads running. Then i created an AdMob account, and added my app in there, created a Bannner ad, like i had in my application, and used the adUnitId, from the AdMob page. But when i ran my Application on my phone i got no ads at all.
In case it matters: The app isn't on the Play Store.
I read that you have to wait several hours, until you get Live-Ads, but i have been waiting for over 12h, and im Still not getting any ads on my Phone.
If you need it, here is my Code:
My AdView:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id"
android:layout_marginBottom="16dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent" />
My onCreate Method:
MobileAds.initialize(getApplicationContext(), "ca-app-pub-hiddenhiddenhide~hiddenhide");
AdView ad = (AdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
ad.loadAd(request);
You need to add this line to the builder.
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
so you need to have something like this:
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
If you want to use your own mobile phone. you can look for the id in the logcat that needs to be added it will look something like this:
AdRequest request = new AdRequest.Builder()
.addTestDevice("here goes your id of your phone")
.build();
The reason why you need to do this is because when you are developing you can't see adds because the app is not placed in the playstore.
As long as he isn't in the playstore you won't see ads. You can create test-ads with the code is just provided
If you go to production try using this code: (it wil use a testdevice for debugging and developing but it will use real adds for your device as well when in production )
AdRequest adRequest = new AdRequest.Builder()
.build();
if (BuildConfig.DEBUG)
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("your id goes here")
.build();

Admob test ad working but not real ad

I added everything to android application as per the instructions from the admob website. On both the emulator and phone i tested my app. The test ads were displaying properly. i generated a signed apk and still it is showing the test ads. what should i do?
here my code:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
in MainActivity:
MobileAds.initialize(getApplicationContext(), "ca-app-pub-9815982880222619/9339487889");
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Please help me!

Not Showing Firebase Test Native Express ads, getting only live ads, also how to make Native express ads fit the width?

i have set test device sill getting live ads..
mAdView = (NativeExpressAdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("722378CE522E161F0EFAD13A658F5161")
.addTestDevice("048B0A7DC3863535720E0C21AC1C58FD")
.build();
mAdView.loadAd(adRequest);
and my xml code is:
<com.google.android.gms.ads.NativeExpressAdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_above="#+id/l2"
ads:adSize="360x80"
ads:adUnitId="#string/native_ads"
/>
For getting test native express ads, use following ad unit id-
<string name="native_ad_test_unit_id">ca-app-pub-3940256099942544/6300978111</string>
For getting full width ads, use the FULL_WIDTH constant in the adSize.
For example, your code should be
<com.google.android.gms.ads.NativeExpressAdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_above="#+id/l2"
ads:adSize="FULL_WIDTHx80"
ads:adUnitId="#string/native_ads"
/>
Use
ca-app-pub-3940256099942544/6300978111
instead of your own Ad unit id.
As described here
https://firebase.google.com/docs/admob/android/native-advanced
it is possible to use
ca-app-pub-3940256099942544/3986624511

Android, admob advert is not displaying

I am trying to implement a banner advert in my Android application. I have used Gradle to download the dependencies, etc.
In my activity where I want the advert to be displayed I have:
<com.google.android.gms.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/ad_mob_id" />
And ad_mob_id is
ca-app-pub-3940256099942544/6300978111
Which is for test ads, I took that from https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start#step_1_modify_the_main_activity_layout
However when I run the activity nothing is displayed and there are no errors/warnings generated.
Am I missing another step?
AdView mAdView = (AdView) getView().findViewById(R.id.adView); // locate the id the banner view
// if you do not use fragments and you are using it directing the remove the getView();
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest); // load it..that's all and you will see logs on it
i took it from the link you posted, it has all you need.

Categories

Resources