gpt4 book ai didi

android - 如何禁用奖励视频显示/播放的后退按钮?

转载 作者:行者123 更新时间:2023-11-29 23:10:10 25 4
gpt4 key购买 nike

在奖励视频播放期间,我想禁用后退按钮并设置最短等待时间。有可能吗?我应该改变哪个功能来完成我想要的功能?这是我的代码

 if (mAd.isLoaded()) {
mAd.show();

} else {
startActivity(new Intent(EssayActivityQstnShow2.this, Essay_Answer_Show.class));
}

这是奖励视频广告的处理方法

    private void loadRewardedVideoAds() {
if (!mAd.isLoaded()) {
mAd.loadAd(getResources().getString(R.string.rewardedvideoid), new AdRequest.Builder().build());
}
}

@Override
public void onRewardedVideoAdLoaded() {
}

@Override
public void onRewardedVideoAdOpened() {
// onBackPressed();


}

@Override
public void onRewardedVideoStarted() {


// onBackPressed();

}

@Override
public void onRewardedVideoAdClosed() {


startActivity(new Intent(EssayActivityQstnShow2.this, Essay_Answer_Show.class));
}

@Override
public void onRewarded(RewardItem rewardItem) {
}

@Override
public void onRewardedVideoAdLeftApplication() {
}

@Override
public void onRewardedVideoAdFailedToLoad(int i) {
loadRewardedVideoAds();
}

@Override
public void onRewardedVideoCompleted() {
startActivity(new Intent(EssayActivityQstnShow2.this, Essay_Answer_Show.class));
}

最佳答案

试试下面的代码

private boolean isVideoPlaying;

@Override
public void onRewardedVideoStarted() {
isVideoPlaying = true;
}

@Override
public void onRewardedVideoAdClosed() {
isVideoPlaying = false;
}

然后 onBackPress() 检查视频是否正在播放

 @Override
public void onBackPressed() {
if (!isVideoPlaying)
super.onBackPressed();
}

在实现之前,请阅读 policies小心。

关于android - 如何禁用奖励视频显示/播放的后退按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56105586/

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