admob 奖励视频不起作用或真实 ID 它仅适用于测试 ID
admob rewarded video not working or real id it works only on test id
我尝试为我的应用程序创建 admob 奖励视频,它在测试应用程序上运行完美,但在真实应用程序上不起作用 one.is admob 制定了任何规则,但我不知道。剂量它需要真实身份被激活的时间
这是我厌倦的代码,其中没有错误,但我认为它适用于测试 ID 但不是真实的
包裹 com.example.median1.helper;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
private RewardedVideoAd mAd;
private TextView mText;
private Button Start;
public int credit=0;
public int sum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mText=(TextView)findViewById(R.id.textView);
MobileAds.initialize(getApplicationContext(),"");
mAd=MobileAds.getRewardedVideoAdInstance(this);
mAd.setRewardedVideoAdListener(this);
loadRewardVideoAd();
}
private void loadRewardVideoAd(){
if(!mAd.isLoaded()){
mAd.loadAd("",new AdRequest.Builder().build());
}else {
Toast.makeText(this, "Please try again later", Toast.LENGTH_SHORT).show();
}
}
public void startvideoadd(View view){
if(mAd.isLoaded()){
mAd.show();
}
}
@Override
public void onRewardedVideoAdLoaded() {
}
@Override
public void onRewardedVideoAdOpened() {
}
@Override
public void onRewardedVideoStarted() {
}
@Override
public void onRewardedVideoAdClosed() {
loadRewardVideoAd();
}
@Override
public void onRewarded(RewardItem rewardItem) {
mText.setText("now you can start");
sum=credit+10;
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
}
@Override
protected void onPause() {
mAd.pause(this);
super.onPause();
}
@Override
protected void onResume() {
mAd.resume(this);
super.onResume();
}
@Override
protected void onDestroy() {
mAd.destroy(this);
super.onDestroy();
}
public void start(View view){
if(sum==10){
Intent Nextpage=new Intent(MainActivity.this,Helper.class);
startActivity(Nextpage);
}else {
Toast.makeText(this, "Please watch a video", Toast.LENGTH_LONG).show();
}
}
}
可能是无填充错误,这意味着 google 无法针对您的特定请求时间提供真正的激励广告(这主要取决于地理位置和广告活动 运行 在这个地理位置)
您只需检查广告失败事件中返回的错误代码:
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
// check the value of I and you will know the failure reason
}
我尝试为我的应用程序创建 admob 奖励视频,它在测试应用程序上运行完美,但在真实应用程序上不起作用 one.is admob 制定了任何规则,但我不知道。剂量它需要真实身份被激活的时间
这是我厌倦的代码,其中没有错误,但我认为它适用于测试 ID 但不是真实的 包裹 com.example.median1.helper;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
private RewardedVideoAd mAd;
private TextView mText;
private Button Start;
public int credit=0;
public int sum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mText=(TextView)findViewById(R.id.textView);
MobileAds.initialize(getApplicationContext(),"");
mAd=MobileAds.getRewardedVideoAdInstance(this);
mAd.setRewardedVideoAdListener(this);
loadRewardVideoAd();
}
private void loadRewardVideoAd(){
if(!mAd.isLoaded()){
mAd.loadAd("",new AdRequest.Builder().build());
}else {
Toast.makeText(this, "Please try again later", Toast.LENGTH_SHORT).show();
}
}
public void startvideoadd(View view){
if(mAd.isLoaded()){
mAd.show();
}
}
@Override
public void onRewardedVideoAdLoaded() {
}
@Override
public void onRewardedVideoAdOpened() {
}
@Override
public void onRewardedVideoStarted() {
}
@Override
public void onRewardedVideoAdClosed() {
loadRewardVideoAd();
}
@Override
public void onRewarded(RewardItem rewardItem) {
mText.setText("now you can start");
sum=credit+10;
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
}
@Override
protected void onPause() {
mAd.pause(this);
super.onPause();
}
@Override
protected void onResume() {
mAd.resume(this);
super.onResume();
}
@Override
protected void onDestroy() {
mAd.destroy(this);
super.onDestroy();
}
public void start(View view){
if(sum==10){
Intent Nextpage=new Intent(MainActivity.this,Helper.class);
startActivity(Nextpage);
}else {
Toast.makeText(this, "Please watch a video", Toast.LENGTH_LONG).show();
}
}
}
可能是无填充错误,这意味着 google 无法针对您的特定请求时间提供真正的激励广告(这主要取决于地理位置和广告活动 运行 在这个地理位置)
您只需检查广告失败事件中返回的错误代码:
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
// check the value of I and you will know the failure reason
}