publicclassMainActivityextendsAppCompatActivity {Adx3BannerAdView bannerview;protectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//TODO use XML to Add AdView bannerview =findViewById(R.id.adView);//TODO use Create to Add AdView bannerview =newAdx3BannerAdView(getContext());bannerview.setAdSize(newAdSize(width,height));bannerview.setUnitId("UnitId");//TODO load the ADbannerview.loadAd(); }}
bannerView.setAdListener(newAdListener() { @Overridepublicvoidshow() {//Code to be executed when the ad has been showed int Screen } @OverridepublicvoidloadFaild() {//Code to be executed when the ad load faild } @OverridepublicvoidloadSucces() {//Code to be executed when the ad load success } @OverridepublicvoidadClose() {//Code to be executed when the ad close by user } @OverridepublicvoidadClick() {//Code to be executed when user click the ad } @OverridepublicvoidadComplate() {//Code to be executed when the ad is finish } @OverridepublicvoidadSkip() {//Code to be executed when user skip the ad not wait for finish it } @OverridepublicvoidclickUrl(String url) {//Code to be executed when user click the ad and tell the url to uesr } });