gpt4 book ai didi

ionic-framework - RewardVideoListener 不是抽象的,不会覆盖 RewardedVideoAdListener 中的抽象方法 onRewardedVideoCompleted()

转载 作者:行者123 更新时间:2023-12-04 00:05:04 25 4
gpt4 key购买 nike

//这是我的代码

package name.ratson.cordova.admob.rewardvideo;

import android.util.Log;

import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;

import org.json.JSONException;
import org.json.JSONObject;

import name.ratson.cordova.admob.AbstractExecutor;

class RewardVideoListener implements RewardedVideoAdListener {
private final RewardVideoExecutor executor;

RewardVideoListener(RewardVideoExecutor executor) {
this.executor = executor;
}

@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
synchronized (executor.rewardedVideoLock) {
executor.isRewardedVideoLoading = false;
}

JSONObject data = new JSONObject();
try {
data.put("error", errorCode);
data.put("reason", AbstractExecutor.getErrorReason(errorCode));
data.put("adType", executor.getAdType());
} catch (JSONException e) {
e.printStackTrace();
}
executor.fireAdEvent("admob.rewardvideo.events.LOAD_FAIL", data);
}

@Override
public void onRewardedVideoAdLeftApplication() {
JSONObject data = new JSONObject();
try {
data.put("adType", executor.getAdType());
} catch (JSONException e) {
e.printStackTrace();
}
executor.fireAdEvent("admob.rewardvideo.events.EXIT_APP", data);
}

@Override
public void onRewardedVideoAdLoaded() {
synchronized (executor.rewardedVideoLock) {
executor.isRewardedVideoLoading = false;
}
Log.w("AdMob", "RewardedVideoAdLoaded");
executor.fireAdEvent("admob.rewardvideo.events.LOAD");

if (executor.shouldAutoShow()) {
executor.showAd(true, null);
}
}

@Override
public void onRewardedVideoAdOpened() {
executor.fireAdEvent("admob.rewardvideo.events.OPEN");
}

@Override
public void onRewardedVideoStarted() {
executor.fireAdEvent("admob.rewardvideo.events.START");
}

@Override
public void onRewardedVideoAdClosed() {
executor.fireAdEvent("admob.rewardvideo.events.CLOSE");
executor.clearAd();
}

@Override
public void onRewarded(RewardItem reward) {
JSONObject data = new JSONObject();
try {
data.put("adType", executor.getAdType());
data.put("rewardType", reward.getType());
data.put("rewardAmount", reward.getAmount());
} catch (JSONException e) {
e.printStackTrace();
}
executor.fireAdEvent("admob.rewardvideo.events.REWARD", data);
}
}

最佳答案

您的 RewardVideoListener 类正在接口(interface)中实现 RewardedVideoAdListener。

为了使用 RewardedVideoAdListener 接口(interface)进行编译,您需要实现包括 RewardedVideoAdListener 在内的所有接口(interface)方法。

所以把这个添加到你的类(class):

@Override
public void onRewardedVideoCompleted() {
Toast.makeText(this, "onRewardedVideoCompleted", Toast.LENGTH_SHORT).show();
}

关于ionic-framework - RewardVideoListener 不是抽象的,不会覆盖 RewardedVideoAdListener 中的抽象方法 onRewardedVideoCompleted(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49504670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com