Tuesday, December 1, 2015

Show Google Ads in Android(AdMob)

show advertising in android mobile like banner or full screen add.


Banner Ads in Android
AdMob in Android
First we need id for ads open https://apps.admob.com/ and monetise application . there are basically two type of ads .

First: Banner Ad (show banner at top or bottom)
Second Full Screen Ad(Interstitial Ads)

Banner Ad show


banner can be adjust according to app it may be top or bottom

add  Google Play Library 

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

AdMob XML File  :


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
 
     <com.google.android.gms.ads.AdView
        android:id="@+id/adMob"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="YOUR BANNER ID" >
    </com.google.android.gms.ads.AdView>

</RelativeLayout>

Manifest Permission

you must have set  internet permission.

 <uses-permission android:name="android.permission.INTERNET" />


Full Screen Ads : 


InterstitialAd mInterstitialAd;
AdRequest adRequestFull;

mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("YOUR ID");

adRequestFull = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build();
mInterstitialAd.loadAd(adRequestFull);






No comments :

Post a Comment