如何实施奖励广告?

时间:2019-05-31 17:50:48

标签: java android admob

我遵循了有关如何使用奖励视频的所有指导,但我的应用在初始化时仍然崩溃

我试图按照指南的所有步骤操作

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Button button = findViewById(R.id.view_btn);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (mRewardedVideoAd.isLoaded()) {
                mRewardedVideoAd.show();
                onRewardedVideoAdClosed();
            }
        }
    });
    // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
    MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
    // Use an activity context to get the rewarded video instance.
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
    mRewardedVideoAd.setRewardedVideoAdListener((RewardedVideoAdListener) this);
    loadRewardedVideoAd();

}

应用崩溃

0 个答案:

没有答案