Basic Adview Tutorial

1. Using SDK Manager to update Google Play Services
2. Import (or create project) the library project “{$installer}\sdk\extras\google\google_play_services\libproject\google-play-services_lib” into workspace.
3. Create your own app, and setting to use the library like the following:

googleplayservicesetting

4. Add the following sample code:

    final AdView mAdView = (AdView) findViewById(R.id.adView);
        
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mAdView.getLayoutParams();
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        mAdView.setLayoutParams(params);
        mAdView.bringToFront();
        AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
        .addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
        .build();

        mAdView.loadAd(adRequest);

Note: After finish, you will see something like the following:

adview

Happy adverting 🙂

Advertisements