Respond to clicks on ads

Last update: 2023-10-02

TVSDK provides you with information so that you can act on click-through ads. As you create your player UI, you must decide how to respond when a user clicks on a clickable ad.

For TVSDK for Android, only linear ads are clickable.
When a user clicks on an ad or a related button, your application must respond. TVSDK provides you with information about the destination URL for the click.

  1. To set up an event listener for TVSDK, and provide the click-through information, register AdClickedEventListener.onAdClicked.

    When a user clicks on an ad or a related button, TVSDK dispatches this notification, including information about the destination for the click.

  2. Monitor user interactions on clickable ads.

  3. When the user touches or clicks the ad or button, to notify TVSDK, call notifyClick on the MediaPlayerView.

  4. Listen for the onAdClick(AdClickEvent event) event from TVSDK.

  5. To retrieve the click-through URL and related information, use the getter methods for the AdClickEvent instance.

  6. Pause the video.

    For more information about pausing the video, see Pause and resume playback.

  7. Use the click-through information to display the ad click-through URL and the related information. You can, for example, display the information in one of the following ways:

    • In your application, by opening the click-through URL in a browser.

      On desktop platforms, the video ad playback area is used to invoke click-through URLs at user clicks.

    • Redirect users to their external mobile web browser.

      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. On these devices, a separate view such as a sponsor button, is used to launch the click-through URL.

  8. Close the browser window in which the click-through information is displayed and resume playing the video.

For example:

private AdStartedEventListener adStartedEventListener =
  new AdStartedEventListener() {
    public void onAdStarted(AdPlaybackEvent adPlaybackEvent) {
        Ad ad = adPlaybackEvent.getAd();
        if (ad == null) {

        _pubOverlay.startAd(adPlaybackEvent.getAdBreak(), ad);

        if (areClickableAdsEnabled() && ad.isClickable()) {
            _isClickableAdPlaying = true;

private AdCompletedEventListener adCompletedEventListener =
  new AdCompletedEventListener() {
    public void onAdCompleted(AdPlaybackEvent adPlaybackEvent) {
        Ad ad = adPlaybackEvent.getAd();
        _pubOverlay.stopAd(adPlaybackEvent.getAdBreak(), ad);

        _isClickableAdPlaying = false;
        if (ad.isClickable()) {

private AdClickedEventListener adClickedEventListener =
  new AdClickedEventListener() {
    public void onAdClicked(AdClickEvent adClickEvent) {
        AdClick adClick = adClickEvent.getAdClick();
        Ad ad = adClickEvent.getAd();

        String url = adClick.getUrl();
        if (url == null || url.trim().equals("")) {
        } else {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(ACTION_VIEW, uri);
            try {
            } catch (Exception e) {

On this page