admobe ads

How to Implement Admob Ads in Your App for Android Studio

admobe ads
How to Place banner and interstitial ads for Android studio WebView application Bangla Tutorial

How to Implement Admob Ads in Your Android App for Studio.

How do you install ad mob ads in your android application? I have shown you through this web page and I have explained in a very beautiful way by picture art how and where to put the ad code codes. I have shown exactly where and how to put them. Through my web page and watching my YouTube videos, you can easily create Android applications in Android Studio and earn money by uploading them to the Play Store by putting ads in the Android applications.

Sample AdMob App test ID:   ca-app-pub-3940256099942544~3347511713
Banner test ID:      ca-app-pub-3940256099942544/6300978111

wev view admobe ads

Copy and paste this code below Add the below dependencies in the build. Gradle and click sync.

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

web view app admobe ads

Copy and paste this code below. your AndroidManifest.xml

<meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="YOUR_ADMOB_APP_ID"/>

web view app for admobe ads

Copy and paste this code below. Open MainActivity.java.

 import com.google.android.gms.ads.MobileAds;

webview app for admobe ads

Copy and paste this code below. Open MainActivity.java.

MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");

webview app for admobe ads

open main_activity.xml
under the RelativeLayout section copy the below code :

<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="SMART_BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
        </com.google.android.gms.ads.AdView>

web view app for admobe ads

Copy and paste this code below.
open MainActivity. in package : 

import com.google.android.gms.ads.AdRequest;
				import com.google.android.gms.ads.AdView;

webview app for admobe ads

in public class:

private AdView mAdView;

webview app for admobe ads

Copy and paste this code below. Open MainActivity.java.

mAdView = findViewById(R.id.adView);
        				AdRequest adRequest = new AdRequest.Builder().build();
        				mAdView.loadAd(adRequest);

web view app for admobe ads

Copy and paste this code below.
open MainActivity. in package :   

import com.google.android.gms.ads.InterstitialAd; 

webview app for admobe ads

Copy and paste this code below in public class:

private InterstitialAd mInterstitialAd;

webview app for admobe ads

Copy and paste this code below. Open MainActivity.java.

 mInterstitialAd = new InterstitialAd(this);

mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.loadAd(new AdRequest.Builder()
        .build());

webview app for admobe ads

Copy and paste this code below. Open MainActivity.java. onbackpress

{
        if (mInterstitialAd.isLoaded()) {
            mInterstitialAd.show();
        } else {
            if (mywebView.canGoBack()) {
                mywebView.goBack();
            } else {
                super.onBackPressed();
            }

            mInterstitialAd.setAdListener(new AdListener() {
                @Override
                public void onAdClosed() {

                    if (mywebView.canGoBack()) {
                        mywebView.goBack();
                    } else {


                        mInterstitialAd.loadAd(new AdRequest.Builder().build());
                    }

                }
            });
        }

    }

}

Leave a Comment

Your email address will not be published. Required fields are marked *