com.google.android.gms.ads.reward.RewardedVideoAdListener Java Examples

The following examples show how to use com.google.android.gms.ads.reward.RewardedVideoAdListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenerateShortcutHelper.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
static void showVideoAd(Activity activity) {
    final RewardedVideoAd ad = MobileAds.getRewardedVideoAdInstance(activity);
    ad.setRewardedVideoAdListener(new RewardedVideoAdListener() {
        @Override
        public void onRewardedVideoAdLoaded() {
            ad.show();
        }

        @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) {

        }
    });
    ad.loadAd(activity.getString(R.string.reward_video_ad_unit_id), new AdRequest.Builder().build());
}
 
Example #2
Source File: MainActivity.java    From Instagram-Profile-Downloader with MIT License 4 votes vote down vote up
private void loadRewardedVideoAd() {


        mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(MainActivity.this);
        mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
            @Override
            public void onRewardedVideoAdLoaded() {

            }

            @Override
            public void onRewardedVideoAdOpened() {
            }

            @Override
            public void onRewardedVideoStarted() {
            }

            @Override
            public void onRewardedVideoAdClosed() {
                closeApp();

            }

            @Override
            public void onRewarded(RewardItem rewardItem) {
            }

            @Override
            public void onRewardedVideoAdLeftApplication() {
            }

            @Override
            public void onRewardedVideoAdFailedToLoad(int i) {
                Log.e(TAG, "onRewardedVideoAdFailedToLoad: " + i);
            }

            @Override
            public void onRewardedVideoCompleted() {
                closeApp();
            }
        });

        mRewardedVideoAd.loadAd(getString(R.string.rewarded_video),
                new AdRequest.Builder()
//                        .addTestDevice("33BE2250B43518CCDA7DE426D04EE231")
                        .build());
    }
 
Example #3
Source File: AdMob.java    From capacitor-admob with MIT License 4 votes vote down vote up
@PluginMethod()
public void prepareRewardVideoAd(final PluginCall call) {
    this.call = call;
    /* dedicated test ad unit ID for Android rewarded video:
        ca-app-pub-3940256099942544/5224354917
    */
    final String adId = call.getString("adId", "ca-app-pub-3940256099942544/5224354917");

    try {
        mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(getContext());

        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mRewardedVideoAd.loadAd(adId, new AdRequest.Builder().build());


                mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
                    @Override
                    public void onRewardedVideoAdLoaded() {
                        call.success(new JSObject().put("value", true));
                        notifyListeners("onRewardedVideoAdLoaded", new JSObject().put("value", true));
                    }

                    @Override
                    public void onRewardedVideoAdOpened() {
                        notifyListeners("onRewardedVideoAdOpened", new JSObject().put("value", true));
                    }

                    @Override
                    public void onRewardedVideoStarted() {
                        notifyListeners("onRewardedVideoStarted", new JSObject().put("value", true));
                    }

                    @Override
                    public void onRewardedVideoAdClosed() {
                        notifyListeners("onRewardedVideoAdClosed", new JSObject().put("value", true));
                    }

                    @Override
                    public void onRewarded(RewardItem rewardItem) {
                        notifyListeners("onRewarded", new JSObject().put("value", true));
                    }

                    @Override
                    public void onRewardedVideoAdLeftApplication() {
                        notifyListeners("onRewardedVideoAdLeftApplication", new JSObject().put("value", true));
                    }

                    @Override
                    public void onRewardedVideoAdFailedToLoad(int i) {
                        notifyListeners("onRewardedVideoAdFailedToLoad", new JSObject().put("value", true));
                    }

                    @Override
                    public void onRewardedVideoCompleted() {
                        notifyListeners("onRewardedVideoCompleted", new JSObject().put("value", true));
                    }
                });
            }
        });


    }catch (Exception ex) {
        call.error(ex.getLocalizedMessage(), ex);
    }

}
 
Example #4
Source File: RewardedVideoAd.java    From admob-plus with MIT License 4 votes vote down vote up
private void createAndLoad(AdRequest adRequest) {
    clear();

    rewardedVideoAd = MobileAds.getRewardedVideoAdInstance(plugin.cordova.getActivity());
    rewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
        @Override
        public void onRewardedVideoAdLoaded() {
            plugin.emit(getLoadedEvent());
        }

        @Override
        public void onRewardedVideoAdOpened() {
            plugin.emit(getOpenedEvent());
        }

        @Override
        public void onRewardedVideoStarted() {
            plugin.emit(Events.REWARD_VIDEO_START);
        }

        @Override
        public void onRewardedVideoAdClosed() {
            plugin.emit(getClosedEvent());
        }

        @Override
        public void onRewarded(RewardItem rewardItem) {
            plugin.emit(Events.REWARD_VIDEO_REWARD);
        }

        @Override
        public void onRewardedVideoAdLeftApplication() {
            plugin.emit(getLeftApplicationEvent());
        }

        @Override
        public void onRewardedVideoAdFailedToLoad(int errorCode) {
            plugin.emit(getFailedToLoadEvent(), buildErrorPayload(errorCode));
        }

        @Override
        public void onRewardedVideoCompleted() {
            plugin.emit(Events.REWARD_VIDEO_COMPLETE);
        }
    });
    rewardedVideoAd.loadAd(adUnitID, adRequest);
}
 
Example #5
Source File: MainActivity.java    From MockSMS with Apache License 2.0 4 votes vote down vote up
private RewardedVideoAdListener rewardsListener() {
    return new RewardedVideoAdListener() {
        @Override
        public void onRewardedVideoAdLoaded() {
            mRewardedVideoAd.show();
        }

        @Override
        public void onRewardedVideoAdOpened() {

        }

        @Override
        public void onRewardedVideoStarted() {

        }

        @Override
        public void onRewardedVideoAdClosed() {

        }

        @Override
        public void onRewarded(RewardItem rewardItem) {
            Extra.getInstance(getBaseContext()).setAdKicked();
            Extra.getInstance(getBaseContext()).setAdFreeExpBool(true);
            Toast.makeText(getBaseContext(), "You're gifted +15 minutes!! Thanks!", Toast.LENGTH_SHORT).show();
            Extra.getInstance(getBaseContext()).setAdFreeExpTimeTill(Extra.getInstance(getBaseContext()).getAdFreeExpTimeTill() + TimeUnit.MINUTES.toMillis(15));
        }

        @Override
        public void onRewardedVideoAdLeftApplication() {

        }

        @Override
        public void onRewardedVideoAdFailedToLoad(int i) {
            Toast.makeText(getApplicationContext(), "No videos are available, please try later", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onRewardedVideoCompleted() {
        }
    };
}
 
Example #6
Source File: AdMob.java    From GodotAds with Apache License 2.0 4 votes vote down vote up
public void createRewardedVideo() {
	mrv = MobileAds.getRewardedVideoAdInstance(activity);
	mrv.setRewardedVideoAdListener(new RewardedVideoAdListener() {

		@Override
		public void onRewardedVideoAdLoaded() {
			Utils.d("GodotAds", "AdMob:Video:Loaded");
			//emitRewardedVideoStatus();
			//Utils.call
			adRewardLoaded = true;
		}

		@Override
		public void onRewarded(RewardItem rewardItem) {
			Utils.d("GodotAds", "AdMob:Rewarded");

			JSONObject ret = new JSONObject();
			try {
				ret.put("RewardType", rewardItem.getType());
				ret.put("RewardAmount", rewardItem.getAmount());
			} catch (JSONException e) {
				Utils.d("GodotAds", "AdMob:Reward:Error:" + e.toString());
			}

			Utils.callScriptFunc("AdMob", "AdMobReward", ret.toString());
			adRewardLoaded = false;
		}

		@Override
		public void onRewardedVideoAdFailedToLoad(int errorCode) {
			Utils.d("GodotAds", "AdMob:VideoLoad:Failed");
			Utils.callScriptFunc("AdMob", "AdMob_Video", "load_failed");
			adRewardLoaded = false;
		}

		@Override
		public void onRewardedVideoAdClosed() {
			Utils.d("GodotAds", "AdMob:VideoAd:Closed");
			adRewardLoaded = false;
		}

		@Override
		public void onRewardedVideoAdLeftApplication() {
			Utils.d("GodotAds", "AdMob:VideoAd:LeftApp");
			adRewardLoaded = false;
		}

		@Override
		public void onRewardedVideoAdOpened() {
			Utils.d("GodotAds", "AdMon:VideoAd:Opended");
			adRewardLoaded = false;
		}

		@Override
		public void onRewardedVideoStarted() {
			Utils.d("GodotAds", "Reward:VideoAd:Started");
			adRewardLoaded = false;
		}

		@Override
		public void onRewardedVideoCompleted() {
			Utils.d("GodotAds", "Reward:VideoAd:Completed");
			adRewardLoaded = false;
			
			createRewardedVideo();
		}
	});

	requestNewRewardedVideo();
}