How to integration google ad in android app. Part - 1

Android Development
January 13, 20212 minutesuserPankaj Valani
How to integration google ad in android app. Part - 1

Dear, Friend in this blog we discussion google ad integration. Many companies work in client base & product base. Product based company in very very important ad integration in the app. Multiple types of AD are available like a Facebook ad, start-up ad, google ad, etc. Today we learning google ad integration.

Type of Google AD:

  • Banner AD
  • Interstitial Ad
  • Rewarded Video Ad
  • Native Ad

1.Banner Ad

Banner Ads occupy only a portion of the screen depending on the ad size that is created. It comes in multiple sizes Standard, Medium, Large, Full-Size, Leaderboard, and Smart Banner. Smart banners are very useful when you target multiple device sizes and fit the same ad depending on the screen size.

2.Interstitial Ads

Interstitial ads occupy the full screen of the app. Basically, they will show on a timely basis, between screen transition or when the user is done with a task.

3.Rewarded Video Ad

This ad shows a video-type ad.

4.Native Ad

In this app in full description ad showing.

Create a new project

Create a new project in Android Studio from File ⇒ New Project.

Open build. Gradle and add play services dependency as AdMob requires it.

compile ‘com.google.android.gms:play-services-ads:11.8.0’

build.gradle
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'

    compile 'ccom.google.android.gms:play-services-ads:11.8.0'
}

Add the App ID and Ad unit IDs to your strings.xml.

    AdMob
    Interstitial
    Welcome to Admob. Click on the below button to launch the Interstitial ad.
    Show Interstitial Ad
    Show Rewarded Video Ad

    ca-app-pub-XXXXXXXX~XXXXXXXXXXX
    ca-app-pub-XXXXXXXX~XXXXXXXXXXX
    ca-app-pub-XXXXXXXX~XXXXXXXXXXX
    ca-app-pub-XXXXXXXX~XXXXXXXXXXX

Create a class named MyApplication.java and extend the class from Application. In this application class, we have to globally initialize the AdMob App Id. Here we use MobileAds.initialize()

MyApplication.java

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
         MobileAds.initialize(this, getString(R.string.admob_app_id));
    }
}

Open AndroidManifest.xml and add MyApplication to tag.

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

Our Laravel Products

InfyHMSInfyHMS-SAASInfyJobsInfyChatInfyCareInfyVCards-SaaSInfyInvoicesInfyInvoices-SaaSInfyCalInfyFundingInfyNews