所以我正在尝试实施视频奖励广告。但是,当我尝试使用onRewarded方法来奖励用户时,它说“方法不会覆盖其超类的方法” https://pastebin.com/Hp1zbuWW
sudo apt-add-repository ppa:webupd8team/java
答案 0 :(得分:0)
我认为您忘记在活动中实施RewardedVideoAdListener。
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
private RewardedVideoAd mRewardedVideoAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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());
}
}
然后你可以覆盖这样的方法。
@Override
public void onRewarded(RewardItem reward) {
Toast.makeText(this, "onRewarded! currency: " + reward.getType() + " amount: " +
reward.getAmount(), Toast.LENGTH_SHORT).show();
// Reward the user.
}
@Override
public void onRewardedVideoAdLeftApplication() {
Toast.makeText(this, "onRewardedVideoAdLeftApplication",
Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdClosed() {
Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdLoaded() {
Toast.makeText(this, "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdOpened() {
Toast.makeText(this, "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoStarted() {
Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}