RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);

        AdView adView = new AdView(this);
        adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
        adView.setAdSize(AdSize.BANNER);

        adView.setLayoutParams(lp);

        RelativeLayout layout = new RelativeLayout(this);

        layout.addView(mView);
        layout.addView(adView);

        AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build();
            
        //adRequest.addTestDevice("AAAA-BBBB-CCCC-D"); // Replace with your test device id

        adView.loadAd(adRequest);

        setContentView(layout);