Android 是否将在foregroundservice中创建的SurfaceTexture显示到活动?

Android 是否将在foregroundservice中创建的SurfaceTexture显示到活动?,android,camera,surface,Android,Camera,Surface,我正在使用我在ForegroundService中创建的SurfaceTexture从相机中捕获视频,而无需使用SurfaceView进行任何活动 如何在活动中显示我的SurfaceTexture 我一直在寻找类似于SurfaceView.setSurfaceTexture()的东西,或者一个采用SurfaceTexture的构造函数,但我什么也找不到。我建议您在服务中创建一个SurfaceView,方法是这样调用构造函数: new SurfaceView(getApplicationConte

我正在使用我在
ForegroundService
中创建的
SurfaceTexture
从相机中捕获视频,而无需使用
SurfaceView
进行任何
活动

如何在
活动
中显示我的
SurfaceTexture


我一直在寻找类似于
SurfaceView.setSurfaceTexture()
的东西,或者一个采用
SurfaceTexture
的构造函数,但我什么也找不到。

我建议您在服务中创建一个
SurfaceView
,方法是这样调用构造函数:

new SurfaceView(getApplicationContext());
因此,由于
SurfaceView
是使用所有应用程序通用的上下文创建的,因此您可以在需要时在
活动的内容视图中正确添加
SurfaceView

否则,您可以查看如何实现一个
MediaPlayer
,该播放器布局由
SurfaceTexture
创建的
Surface