Admob Rewarded Video - Ad Not Loading

2k views Asked by At

I have to implement Admob Reward Video in the android studio in my current project. I have tried everything like.. Youtube tutorial, Admob Official tutorials and scripts but nothing is working for me. Please Help. Looking forward to having example android studio project in which reward video is implemented and working.

This is the code I use:

package easyload.android.el.com.easyloadpk;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.AdView;
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 OurSurvey extends AppCompatActivity implements RewardedVideoAdListener
{
    private RewardedVideoAd rvd;
    Button                  btn;
    private AdView          mAdView;
    TextView                txt;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_our_survey);

        btn     = (Button) findViewById(R.id.btnad);
        mAdView = findViewById(R.id.adView);
        txt     = (TextView) findViewById(R.id.textView);

     //...............................................................................
     //   AdRequest adRequest = new AdRequest.Builder().build();
     //   mAdView.loadAd(adRequest);
     //...............................................................................

        MobileAds.initialize(this,"ca-app-pub-3940256099942544~3347511713");
        rvd = MobileAds.getRewardedVideoAdInstance(this);
        rvd.setRewardedVideoAdListener(this);
      //................................................................................
        loadad();
      //  AdView adView = new AdView(this);
       // adView.setAdSize(AdSize.BANNER);
      //  adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
       //...............................................................................

        btn.setOnClickListener(new View.OnClickListener()
        {
          @Override
          public void onClick(View v)
          {
            if(rvd.isLoaded()){
                rvd.show();
            }
            else{
                txt.setText("cnt");
            }
          }
        });
    }

    private void loadad()
    {
      rvd.loadAd("ca-app-pub-3940256099942544/5224354917",new AdRequest.Builder().build());
    }

    @Override
    public void onRewardedVideoAdLoaded()
    {
      txt.setText("holalalala");
    }

    @Override
    public void onRewardedVideoAdOpened() {

    }

    @Override
    public void onRewardedVideoStarted() {

    }

    @Override
    public void onRewardedVideoAdClosed() {

    }

    @Override
    public void onRewarded(RewardItem rewardItem) {

    }

    @Override
    public void onRewardedVideoAdLeftApplication() {

    }

    @Override
    public void onRewardedVideoAdFailedToLoad(int i) {

    }

    @Override
    public void onRewardedVideoCompleted() {

    }

    @Override
    public void onResume()
    {
      rvd.resume(this);
      super.onResume();
    }

    @Override
    public void onPause()
    {
      rvd.pause(this);
      super.onPause();
    }
}

Thank You

0

There are 0 answers