admob奖励视频不工作或真正的ID只适用于测试ID

时间:2018-01-11 21:35:50

标签: admob google-admob

我试图为我的应用程序创建admob奖励视频它在测试应用程序上完美运行但它不适用于真正的一个。有任何规则,admob放,我不知道.Dose它需要时间,直到真实id被激活

这是我厌倦的代码并且没有错误,但是认为它适用于测试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();
  }

    }


}

1 个答案:

答案 0 :(得分:1)

这可能是一个没有填充错误的问题,这意味着谷歌无法为您的特定时间段提供真正的奖励广告(主要取决于Geo和在此Geo中运行的广告活动)

您只需检查广告失败事件中返回的错误代码:

@Override
public void onRewardedVideoAdFailedToLoad(int i) {
    // check the value of I and you will know the failure reason
}