MREC

SDK 6.4.8及以上才支持MREC广告。MREC采用移动广告行业的标准样式,长宽为300dp × 250dp。

请求广告


// Load Ad Implementation
if (Vungle.isInitialized()) {
    Vungle.loadAd("YOUR_MREC_PLACEMENT_REFERENCE_ID", new LoadAdCallback() {
        @Override
        public void onAdLoad(String placementReferenceId) { }

        @Override
        public void onError(String placementReferenceId, VungleException e) {
            // Load ad error occurred - e.getLocalizedMessage() contains error message
        }
    });
}

播放广告


private ConstraintLayout mrec_container;
private VungleNativeAd vungleNativeAd;
private View nativeAdView;

...

AdConfig adConfig = new AdConfig();
adConfig.setAdSize(AdConfig.AdSize.VUNGLE_MREC);
// Mute
// adConfig.setMuted(true); 

flexfeed_container = findViewById(R.id.mlayout);
vungleNativeAd =Vungle.getNativeAd("YOUR_MREC_PLACEMENT_REFERENCE_ID", adConfig, new PlayAdCallback() {
        @Override
        public void onAdStart(String id) { 
            // Ad experience started
        }

        @Override
        public void onAdEnd(String id) {
            // Ad experience ended
        }

        @Override
        public void onAdClick(String id) {
            // User clicked on ad
        }

        @Override
        public void onAdRewarded(String id) {
            // User earned reward for watching an ad
        }

        @Override
        public void onAdLeftApplication(String id) {
            // User has left app during an ad experience
        }

        @Override
        public void onError(String id, VungleException exception) { 
            // Ad failed to play
        }
});

if(vungleNativeAd != null){
    nativeAdView = vungleNativeAd.renderNativeView();
    mrec_container.addView(nativeAdView);
}

暂停广告

vungleNativeAd.setAdVisibility(false);

恢复播放

vungleNativeAd.setAdVisibility(true);

关闭广告

vungleNativeAd.finishDisplayingAd();
Powered by Creativity Driven by Performance Sign Up Here

Questions?

Need further assistance, feel free to reach out to us, we’re here to help!

这篇文章有帮助吗?