How to Add Banner Ads in Android Studio || Banner Ads in Android Studio Java || #2024

0 minute read
0


Admob Banner Ad in Android Studio Java.






How to implement Banner Ad in Android Studio Java?




Solution:


1: First You add Google Admob Ad Dependency


    implementation 'com.google.android.gms:play-services ads:22.6.0'
 

2: Second You add Meta-data in Manifest file
 

   <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3940256099942544~3347511713"/>



XML layout... Banner Ads



 <com.google.android.gms.ads.AdView

        android:id="@+id/adView"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        app:adSize="BANNER"

        app:adUnitId="ca-app-pub-3940256099942544/6300978111"

        android:layout_centerHorizontal="true"

        android:layout_alignParentBottom="true">

    </com.google.android.gms.ads.AdView>




Java Class Activity 

AdView adView;


..........................


 adView=(AdView)findViewById(R.id.adView);

        AdRequest adRequest = new AdRequest.Builder().build();

        adView.loadAd(adRequest);

Post a Comment

0Comments

Post a Comment (0)
Today | 1, April 2025