Interstitials will be rendered using the HyBid SDK.

Requirements:

  • Ad Zone Id from the PubNative Publisher Dashboard

Code sample

You can find a demo app with code samples for this type of integration here.

Create HyBidInterstitialAd attribute in you activity or fragment

private HyBidInterstitialAd mInterstitial;

Request the ad

Create an instance of the interstitial object using the zone id and setting a listener. Use the load method to make an ad request.

private void loadInterstitial() {
    mInterstitial = new HyBidInterstitialAd(this,"ZONE_ID", new HyBidInterstitialAd.Listener() {
        @Override
        public void onInterstitialLoaded() {
                
        }

        @Override
        public void onInterstitialLoadFailed(Throwable error) {
                
        }

        @Override
        public void onInterstitialImpression() {
                
        }

        @Override
        public void onInterstitialDismissed() {
                
        }

        @Override
        public void onInterstitialClick() {
                
        }
    });
    mInterstitial.load();
}

Display the ad

After the ad is successfully retrieved from the server, the onInterstitialLoaded callback will notify that the ad is ready to be displayed.

You can display the interstitial as soon as it's loaded using after getting the callback. Use the show method to display the ad:

mInterstitial = new HyBidInterstitialAd(this,"", new HyBidInterstitialAd.Listener() {
    @Override
    public void onInterstitialLoaded() {
        mInterstitial.show();    
    }

    @Override
    public void onInterstitialLoadFailed(Throwable error) {
                
    }

    @Override
    public void onInterstitialImpression() {
                
    }

    @Override
    public void onInterstitialDismissed() {
                
    }

    @Override
    public void onInterstitialClick() {
                
    }
});

If you don't want to show the ad right away after being loaded, you can use the isReady method that returns a boolean stating if the ad has been loaded and is ready to be displayed.

if (mInterstitial.isReady()) {
    mInterstitial.show();
}

Finally destroy the interstitial when the activity or fragment are destroyed

@Override
public void onDestroy() {
    if (mInterstitial != null) {
        mInterstitial.destroy();
    }
    super.onDestroy();
}