1

I encountered a strage thing when I use TextureView on my work. I implemented the 4 methods of SurfaceTextureListener:

onSurfaceTextureAvailable
onSurfaceTextureSizeChanged
onSurfaceTextureDestroyed
onSurfaceTextureUpdated

Doing such a thing is quite easy, it's unnecessary to paste my code.

There is no doubt that onSurfaceTextureAvailable will be called when the activity is started and onSurfaceTextureDestroyed will be called when the activity is destroyed.

But things changed in the case of foreground and backgroud switching.

For most devices, onSurfaceTextureAvailable and onSurfaceTextureDestroyed are not called during foreground and backgroud switching.

But for some devices such as Coolpad 8670 with android 4.4.2, onSurfaceTextureDestroyed is called when the activity go to backgroud and onSurfaceTextureAvailable is called when the activity return to foregroud.

I don't know why.

Is there a way of avoiding the calling of onSurfaceTextureDestroyed when activity go to background for all devices?

dragonfly
  • 1,151
  • 14
  • 35
  • @fadden please have a look. – dragonfly Jul 08 '15 at 12:46
  • FWIW, I don't get a notification when you put "@fadden" in comments. I think the system might have sent them at some point, but it doesn't now. I find questions by keyword. – fadden Jul 08 '15 at 15:40
  • I don't know why you're seeing different behavior on different devices. It's possible to preserve the SurfaceTexture across Activity restarts with some effort. You can find an example in Grafika's "double decode" Activity, which chooses to retain them across orientation changes but not when the app goes to the background. – fadden Jul 08 '15 at 15:44
  • I found that onSurfaceTextureDestroyed is also called on htc m8w with android 5.0.1 and nexus 6 with android 5.0.1 in case of foreground and background switching. I guess that maybe this is the feature of higher android platforms. – dragonfly Jul 09 '15 at 04:03
  • "@fadden" is not a good way to contact with you,are there any other ways? Do you have any IDs such as google, msn.....? – dragonfly Jul 09 '15 at 05:36
  • If you tag the question with one of the tags I watch, I'll find it. If the set of relevant tags for the question doesn't overlap with the tags I watch, then I probably don't know the answer. – fadden Jul 09 '15 at 19:28
  • I have visited your SO profile, but I could not find the tags you are watching. Where are they? By the way, please take a look at this: http://stackoverflow.com/questions/31317503/picture-produced-by-saveframe-of-grafika-is-upside-down – dragonfly Jul 10 '15 at 02:21
  • @fadden Please take a look at this:http://stackoverflow.com/questions/31509201/soft-reference-does-not-behave-as-expected-on-android – dragonfly Jul 20 '15 at 05:14

0 Answers0