AdMob in Android |
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 :
<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