Reputation: 408
I am using a vungle app-id in my app and I want to increment the wallet of the user, only if the video ad is completely seen by user.
//code in my Activity
final VunglePub vunglePub = VunglePub.getInstance();
final String app_id= "58d46c1feba9a90a1a000011"; //vungleid
vunglePub.init(this,app_id);
final EventListener vungleListener= new EventListener() {
@Override
public void onAdEnd(boolean b, boolean b1) {
Update();
}
};
I am trying to update the wallet of user by calling Update method from onAdEnd method of listener but it updates the wallet even if the user closes the ad.
I am trying vungle for the first time, also searched a lot but didnt got my answer. Any help regarding this is appreciated. Thanks!..
Upvotes: 0
Views: 237
Reputation: 71
I am Gabor, working as Intergation Engineer @Vungle.
You can check our documentation here to see how you can use the event listeners. https://support.vungle.com/hc/en-us/articles/204463100-Advanced-Settings-for-Vungle-Android-SDK
The above recommended onVideoView() was depricated, and you should use
@Override
public void onAdEnd(boolean wasSuccessfulView, boolean wasCallToActionClicked) {
// Called when the user leaves the ad and control is returned to your application
// if wasSuccessfulView is true, the user watched the ad and should be rewarded
// (if this was a rewarded ad).
// if wasCallToActionClicked is true, the user clicked the call to action
// button in the ad.
}
If the ad completely by the user, the wasSuccessfulView boolean will be true.
If you have more question feel free to contact us at [email protected] and we will help you out.
Gabor
Upvotes: 2
Reputation: 4328
Try This
VunglePub vunglePub = VunglePub.getInstance();
vunglePub.setEventListeners(vungleEventListener);
Event Listner
private final EventListener vungleEventListener = new EventListener() {
@Override
public void onVideoView(boolean arg0, int arg1, int arg2) {
if (arg0) {
addHint(getResources().getInteger(R.integer.videoHints));
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, "5 Hints added", Toast.LENGTH_SHORT).show();
}
});
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, "Watch Complete video to add hints", Toast.LENGTH_SHORT).show();
}
});
}
}
@Override
public void onAdUnavailable(final String arg0) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, arg0, Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onAdStart() {
}
@Override
public void onAdEnd(boolean arg0) {
initialiseVungle();
}
@Override
public void onAdPlayableChanged(boolean arg0) {
Toast.makeText(context, "You cannot play any ad now. Try after sometime", Toast.LENGTH_LONG).show();
}
};
Upvotes: 0