Search code examples
androidandroid-textureview

onSurfaceTextureDestroyed is not called even when activity is destroyed


I have a Texture View , For which i have set setSurfaceTextureListener . I use this texture view to show live camera feed in my app. I am handling BACK KEY in app explicitly . On BACK KEY press i call " finish() " method to destroy my activity . The " onDestroy " Method of the activity gets called .

But the " onSurfaceTextureDestroyed " method which i have set on my texture View does not get called . I am not sure if it's OK to link this problem with android version But , Interestingly " onSurfaceTextureDestroyed " gets called when i use my app on KITKAT . Its giving problem on Jelly Beans.

Also As i check , When i press HOME Key :- On jelly beanonPause and onStop gets called . But On KITKAT onPause and onStop and onDestroy all three gets called.

I want to know why " onSurfaceTextureDestroyed " is not called even when activity's " onDestroy " is called .


Solution

  • I got the issue . I was setting the setSurfaceTextureListener to null on activity Ondestroy . Thats why it was not being called.