MREC

SDK 6.4.8及以上才支持MREC广告。MREC采用移动广告行业的标准样式,长宽为300dp × 250dp。和FlexFeed相同,可以将该广告在任意位置展示。

注意

测试模式,无法测试MREC广告。请将应用在Vungle Dashboard中设置为有效模式。

请求广告


// 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, Throwable throwable) {
            // Load ad error occurred - throwable.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 placementReferenceId) { }

    @Override
    public void onAdEnd(String placementReferenceId, boolean completed, boolean isCTAClicked) {
        // Calling finishDisplayingAd when you want to finish displaying In-Feed Ad
        // will trigger onAdEnd and will tell you when you can remove the child
        // In-Feed view container vungleNativeAd.finishDisplayingAd();

        // And removing empty ad view from container
        mrec_container.removeView(nativeAdView);
        vungleNativeAd = null;
    }

    @Override
    public void onError(String placementReferenceId, Throwable throwable) {
        // Play ad error occurred - throwable.getLocalizedMessage() contains error message
    }
});

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

暂停广告

vungleNativeAd.setAdVisibility(false);

恢复播放

vungleNativeAd.setAdVisibility(true);

关闭广告

vungleNativeAd.finishDisplayingAd();
这篇文章有帮助吗?

Questions?

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