Could some one please show me a way of implementing video ads?
This is my code…please help someone
import android.os.Looper;//for setup() if needed
import android.os.Bundle;
import android.view.Window;
import android.widget.RelativeLayout;
import android.app.Activity;
//import com.google.ads.*;//
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.MobileAds;
private RewardedVideoAd mRewardedVideoAd;
private RewardedVideoAdListener r;
public void setup(){
size(800, 1000);
}
public void draw(){
background(100);
rect(100,100,100,100);
}
@ Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getActivity().getWindow();
RelativeLayout adsLayout = new RelativeLayout(this.getActivity());
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
MobileAds.initialize(this.getActivity(), “ca-app-pub-3940256099942544~3347511713”);
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this.getActivity());
mRewardedVideoAd.setRewardedVideoAdListener®;
loadRewardedVideoAd();
window.addContentView(adsLayout,lp2);
}
private void loadRewardedVideoAd()
{
mRewardedVideoAd.loadAd(“ca-app-pub-3940256099942544/5224354917”,
new AdRequest.Builder().build());
}
public void onRewardedVideoAdFailedToLoad(int errorCode) {
loadRewardedVideoAd();
}
public void onRewardedVideoAdLoaded() {
if (mRewardedVideoAd.isLoaded())
{
print("uck");
mRewardedVideoAd.show();
}
}