我正在使用 SurfaceTexture
我在 ForegroundService
中创建的无需任何视频即可从相机捕获视频 Activity
与 SurfaceView
.
如何显示我的 SurfaceTexture
在 Activity
?
我一直在寻找类似 SurfaceView.setSurfaceTexture()
的东西或接受 SurfaceTexture
的构造函数但我找不到任何东西。
最佳答案
我建议你创建一个 SurfaceView
在服务中通过调用构造函数像这样:
new SurfaceView(getApplicationContext());
因此,作为
SurfaceView
的上下文使用所有应用程序通用的上下文创建,您可以正确添加您的 SurfaceView
在 Activity
的内容 View 中当你需要的时候。否则,您可以查看this answer实现
MediaPlayer
列出了一个 Surface
由 SurfaceTexture
创建.
关于android - 显示在前台服务中创建的 SurfaceTexture 到 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49756666/