The problem is I created Camera
in a activity, I can get easy show camera preview on activity. But I want create a Presentation
in same activity and also want to make presentation can show camera preview. I know through Camera.PreviewCallBack
I can get a bytes array, use this array I can draw another preview on canvas. But I don't know how to pass this bytes array to presentation in real time, maybe I don't need to do that. I am not sure.
If you have more better suggestion please make me know.
Show two preview in Presentation and Activity, we can through Camera.Preview get data array which is YUV_420_888, through Android Livedata we can pass real-time data to PresentationFragment, then we can through Bitmap to convert data then show preview image on Presentation.
Using TextureView in PresentationFragment, then getSurfaceTexture, create getSurfaceTexture() in fragment, in Activity call getSurfaceTexture, then use this SurfaceTexture get camera preview. But there is a little tricky, when I first time to call getSurfaceTexture() I got "null object reference", I found when I call getSurfaceTexture() in onResume(), onCreateView() in PresentationFragment maybe has not been called, so we need crate a listener or others function to handle if onCreateView() finished then call getSurfaceTexture;