I am trying to register a CameraManager.TorchCallback using CameraManager.registerTorchCallback into a specific thread (ie: different from the UI Thread).
My code is quite basic for an Camera2 implementation:
If I run that code in the main thread, everything is working great, when I run it into another thread class (overriding run
), the callback is never called. I am ensuring that my thread is not terminated, visible on the Android studio profiler. There is something with the registration and the threading I don't understand.
Have you ever tried that kind of implementation?
Any idea is welcome!
Even if you call registerTorchCallback() from a background thread, the callback will still be posted to UI thread. You must create a new HandlerThread and get a Handler for it.