NjkIce

Jun 10, 2021

3 min read

WORD RIDDLE GAME FEATURING HUAWEI ADS KIT (Interstitial and Banner Ads) Part 2

INTRODUCTION

<com.huawei.hms.ads.banner.BannerViewandroid:id="@+id/hw_banner_view"android:layout_width="match_parent"android:layout_height="92dp"android:layout_gravity="fill_vertical|end"hwads:adId="testw6vs28auh3"hwads:bannerSize="BANNER_SIZE_320_50"hwads:layout_constraintBottom_toBottomOf="parent"hwads:layout_constraintEnd_toEndOf="parent"hwads:layout_constraintStart_toStartOf="parent"hwads:layout_constraintVertical_bias="1.0" />
adFrameLayout = findViewById(R.id.ad_frame);bannerView = new BannerView(this);bannerView.setAdId("testw6vs28auh3");BannerAdSize adSize = BannerAdSize.BANNER_SIZE_SMART;bannerView.setBannerAdSize(adSize);adFrameLayout.addView(bannerView);bannerView.loadAd(new AdParam.Builder().build());
private void loadinterstitialAd(){interstitialAd = new InterstitialAd(this);interstitialAd.setAdId("testb4znbuh3n2");interstitialAd.setAdListener(adListener);AdParam adParam= new AdParam.Builder().build();interstitialAd.loadAd(adParam);}
public void adEvent(){adListener =new AdListener(){@Overridepublic void onAdLoaded(){super.onAdLoaded();Toast.makeText(ResultActivity.this, "Ad loaded", Toast.LENGTH_SHORT).show();//display the interstitial adshowInterstitial();}}private void showInterstitial(){//display the interstitial adif(interstitialAd!=null && interstitialAd.isLoaded()){interstitialAd.show();}else{startActivity(new Intent(ResultActivity.this, MainActivity.class));}}