2

我尝试了以下代码(main_activity.java)

        MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
// Use an activity context to get the rewarded video instance.
        mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
        mRewardedVideoAd.setRewardedVideoAdListener(this);
        loadRewardedVideoAd();
    }

    private void loadRewardedVideoAd() {
        mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
                new AdRequest.Builder().build());

        if (mRewardedVideoAd.isLoaded()) {
            mRewardedVideoAd.show();
        }

logcat 说,广告已加载但未显示。我想在单独的片段中显示广告,所以“(这个)”可能是错误的?

感谢您的帮助...请参阅此参考:https ://developers.google.com/admob/android/rewarded-video

4

1 回答 1

5

我修好了它:

 @Override
    public void onRewardedVideoAdLoaded() {
        mRewardedVideoAd.show();
    }
于 2017-11-13T18:58:45.667 回答