Skip to main content
A VideoAds belongs to the episode the viewer watches: create it when the screen opens, and destroy() it with whatever owns it.
  • Owned by a ViewModel: destroy() in onCleared(), and in every new Activity track its player. The ads survive a rotation, and so does the ad on screen, which outlives the Activity: set its listener from the current screen, again after every recreation, and clear it in onDestroy(), so onAdEnded never reaches a destroyed Activity (a listener left from the old screen also keeps it alive).
  • Owned by the Activity, a Fragment or a Compose DisposableEffect: destroy() in its onDestroy() (onDispose), every time. A rotation or another configuration change destroys and recreates the Activity, and the ads with it: declare android:configChanges for rotation, as the example app does, so a rotation does not recreate it.
  • A VideoAds its owner forgot is never released: it holds its player adapter, its ads and their listeners.
  • A linear ad runs in the SDK’s own Activity, over yours. Yours is stopped meanwhile and may be destroyed and recreated (a rotation, the system reclaiming memory); with the VideoAds in a ViewModel, or for a rotation in an Activity that declares android:configChanges, the ad keeps playing, and its end reaches the listener it was shown with.
  • A player Activity with launchMode="singleInstance" is not supported for linear ads: the ad opens in another task, and the viewer returns there. Use standard, singleTop or singleTask.
  • The example app keeps its player Activity across rotation with android:configChanges and calls ads.destroy() in every onDestroy().
  • The ad holds its listener until onAdEnded has run, so a listener that is your Activity stays reachable until the ad ends.