尝试这个
VunglePub vunglePub = VunglePub.getInstance();
vunglePub.setEventListeners(vungleEventListener);
事件监听器
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();
}
};