When a user clicks on an ad or a related button, your application is responsible for responding. The PSDK provides you with information about the destination URL for the click.
On desktop platforms, the video ad playback area is typically used for invoking click-through URLs upon user clicks.
On mobile devices, the video ad playback area is used for other functions, such as hiding and showing controls, pausing playback, expanding to full screen, and so on. Therefore, on mobile devices, a separate view, such as a sponsor button, is usually presented to the user as a means to launch the click-through URL.
private final MediaPlayer.AdPlaybackEventListener _adPlaybackEventListener =
new MediaPlayer.AdPlaybackEventListener() {
...
}
@Override
public void onAdStart(AdBreak adBreak, Ad ad) {
//TODO: Implement external tracking logic
//TODO: Notify the user that an ad has started by an UI update
// Notify the user that the ad is clickable
if (ad.isClickable()) {
//TODO: Modify the UI to give the user the possibility to
choose to click upon the primary asset
}
}
@Override
public void onAdClick(AdBreak adBreak, Ad ad, AdClick adClick) {
// Open the native browser to display the click through url
Uri uri = Uri.parse(adClick.getUrl());
Intent intent = new Intent(ACTION_VIEW, uri);
try {
startActivity(intent);
} catch (Exception e) {
// Log exception
}
}