Once the AdView is in place, the next step is to load an ad. That's done with the loadAd() method in the AdViewclass. It takes an AdRequest parameter, which holds runtime information (such as targeting info) about a single ad request.

Here's an example that shows how to load an ad in the onCreate() method of an Activity:

MainActivity.java (excerpt)

package ...

import ...
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

public class MainActivity extends AppCompatActivity {
private AdView mAdView;

protected void onCreate(Bundle savedInstanceState) {


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


That's it! Your app is now ready to display banner ads.