【问题标题】:Native ad mute reasons not showing?原生广告静音原因未显示?
【发布时间】:2019-09-16 12:18:26
【问题描述】:

由于某种原因,当我尝试将原生广告静音时,它会返回一个空对话框,并且没有理由将原生广告静音。

我从这里得到代码 https://github.com/googlesamples/android-ads/blob/master/advanced/APIDemo/app/src/main/java/com/google/android/gms/example/apidemo/AdMobCustomMuteThisAdFragment.java

我的原生广告静音代码

private void showMuteReasonsDialog() {
        class MuteThisAdReasonWrapper {
            MuteThisAdReason reason;

            MuteThisAdReasonWrapper(MuteThisAdReason reason) {
                this.reason = reason;
            }

            @Override
            public String toString() {
                return reason.getDescription();
            }
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
        builder.setTitle("Select a reason");
        final List<MuteThisAdReason> reasons = nativeAd.getMuteThisAdReasons();
        final List<MuteThisAdReasonWrapper> wrappedReasons = new ArrayList<>();
        for (MuteThisAdReason reason : reasons) {
            wrappedReasons.add(new MuteThisAdReasonWrapper(reason));
        }

        builder.setAdapter(
                new ArrayAdapter<>(MainActivity.this,
                        android.R.layout.simple_list_item_1, wrappedReasons),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        muteAdDialogDidSelectReason(wrappedReasons.get(which).reason);
                    }
                });

        builder.show();
    }



private void muteAdDialogDidSelectReason(MuteThisAdReason reason) {
        // Report the mute action and reason to the ad.
        // The ad is actually muted (removed from UI) in the MuteThisAdListener callback.
        nativeAd.muteThisAd(reason);
    }

private void muteAd() {
        // Disable mute button, remove ad.
        mCloseAd.setEnabled(false);
        mNativeAdContainer.removeAllViews();
    }

请求静音

 NativeAdOptions adOptions = new NativeAdOptions.Builder()
                .setVideoOptions(videoOptions)
                .setRequestCustomMuteThisAd(true)
                .build();

编辑

unifiedNativeAd.isCustomMuteThisAdEnabled() 会返回 false,即使我在 NativeAdOptions 中启用了它?

这是因为我在使用测试广告吗?

【问题讨论】:

    标签: java android admob ads native-ads


    【解决方案1】:

    检查一次,如果您在将其设置为 True 后构建广告加载器。比如这样的。

    adLoader = new AdLoader.Builder(context, "ad unit ID").withNativeAdOptions(new NativeAdOptions.Builder()
                             .setRequestCustomMuteThisAd(true)
                             .build()).build();
        adLoader.loadAd(new AdRequest.Builder().build());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      • 2018-02-02
      • 2021-10-27
      • 2016-09-06
      相关资源
      最近更新 更多