I am using exoplayer for playback in my android tv application.This exoplayer itself I am holding in controller class which I access from my fragment. Currently I have triggered an API in the STATE_ENDED of exoplayer. But inorder to avoid memory leak and other purposes I am making my controller null in the onDestroy of fragment. Hence before API triggering is completed the job gets cancelled.
The player exits when user clicks back button on RCU, at the same time exoplayer goes to STATE_ENDED and api triggering portion gets exectued