Wednesday, 16 July 2014

Admob using google play service library

import google play service lib from  folder where your android sdk placed-> extras-> google -> google play services -> lib project ->google play services lib

add below code in your .java file
--------------------------------------------

  AdRequest request = new AdRequest.Builder()
   .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
   .build();


AdView adView = new AdView(this);
adView.setAdUnitId("your add id");
adView.setAdSize(AdSize.BANNER);

adView.loadAd(request);

LinearLayout lay=(LinearLayout)findViewById(R.id.adView);
lay.addView(adView);



add below code in your xml file
-----------------------------------------------

 <LinearLayout
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top|left"
        android:orientation="vertical">
           
         </LinearLayout>

No comments:

Post a Comment