protected void onFreeWheelEvent(IEvent event) {
   Log.i(CLASSTAG, event.getType());
   if (event.getType().equals(adConstants.EVENT_REQUEST_COMPLETE())) {
     Log.d(CLASSTAG, "ad request complete");
     try {
       Thread.sleep(5000);
     } catch (InterruptedException e) {
     }
     this.prerollSlots =
         adContext.getSlotsByTimePositionClass(adConstants.TIME_POSITION_CLASS_PREROLL());
     this.postrollSlots =
         adContext.getSlotsByTimePositionClass(adConstants.TIME_POSITION_CLASS_POSTROLL());
     this.showDisplayAd();
     this.prepareMidRoll();
     this.playAdSlot(adConstants.TIME_POSITION_CLASS_PREROLL());
   } else if (event.getType().equals(adConstants.EVENT_SLOT_ENDED())) {
     String customId = (String) event.getData().get(adConstants.INFO_KEY_CUSTOM_ID());
     ISlot endedSlot = adContext.getSlotByCustomId(customId);
     if (endedSlot.getTimePositionClass() == adConstants.TIME_POSITION_CLASS_PREROLL()
         || endedSlot.getTimePositionClass() == adConstants.TIME_POSITION_CLASS_POSTROLL()) {
       this.playAdSlot(endedSlot.getTimePositionClass());
     }
   } else if (event.getType().equals(adConstants.EVENT_REQUEST_CONTENT_VIDEO_RESUME())) {
     this.resumeMainVideo();
   } else if (event.getType().equals(adConstants.EVENT_REQUEST_CONTENT_VIDEO_PAUSE())) {
     this.pauseMainVideo();
   }
 }
  public void sendAdRequestToFreeWheel() {
    IEventListener eventListener =
        new IEventListener() {
          public void run(final IEvent event) {
            onFreeWheelEvent(event);
          }
        };

    adContext = AdPreviewer.ADMANAGER.newContext();
    adContext.setActivity(this);
    adConstants = adContext.getConstants();
    adContext.registerVideoDisplay(this.adHolder);

    adContext.addEventListener(adConstants.EVENT_REQUEST_COMPLETE(), eventListener);
    adContext.addEventListener(adConstants.EVENT_SLOT_ENDED(), eventListener);
    adContext.addEventListener(adConstants.EVENT_REQUEST_CONTENT_VIDEO_PAUSE(), eventListener);
    adContext.addEventListener(adConstants.EVENT_REQUEST_CONTENT_VIDEO_RESUME(), eventListener);

    if (this.previewJson) {
      adContext.addRenderer(
          this.HTMLTranslatorClass,
          null,
          null,
          "image/png,image/gif,image/jpeg,text/html,text/js_ref,text/javascript",
          "preroll,midroll,postroll,overlay,display",
          null);
    }
    adContext.submitRequest(10.0);
  }