最小化后android相机工作

标签 android camera minimize

您可能会注意到,当我们将其最小化时(例如,当我们启动一个新应用程序时),Android 手机中的摄像头会停止工作。我的问题是:有没有什么方法可以创建一个带有 android 相机的应用程序,即使我们将它最小化,它也会记录下来,这样它就可以在我们在手机上做一些不同的事情时录制视频?或者只有在不使用 MediaStore 的情况下创建这样的相机才有可能?如果您分享一些可能对我有帮助的链接或代码,我将不胜感激。提前致谢。

最佳答案

我相信答案是必须使用

public final void setPreviewTexture (SurfaceTexture surfaceTexture)

Added in API level 11
Sets the SurfaceTexture to be used for live preview. 
Either a surface or surface texture is necessary for preview, 
and preview is necessary to take pictures.

来自 https://developer.android.com/reference/android/hardware/Camera.html .和 来自 https://developer.android.com/reference/android/graphics/SurfaceTexture.html :

The image stream may come from either camera preview or video decode. 
A SurfaceTexture may be used in place of a SurfaceHolder when specifying the 
output destination of a Camera or MediaPlayer object. Doing so will cause all the 
frames from the image stream to be sent to the SurfaceTexture object rather than 
to the device's display.

我真的很想试试这个并给你发一些代码,但我没有比 Gingerbread 更新的手机了,这是用 hive 引入的。

使用与 Activity 关联的 surfacesurfaceDestroyedonPauseonStop 之间的某个时间调用,当 Activity正在最小化,尽管奇怪的是,当手机进入休眠状态时却没有:How SurfaceHolder callbacks are related to Activity lifecycle?但我希望 surfaceTexture 不会以这种方式被破坏。

关于最小化后android相机工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13886360/

相关文章:

python - scipy.minimize - "TypeError: numpy.float64' 对象不可调用运行”

c# - 仅在 wpf 上显示 X 和最小化按钮

java - 从 Android 设备到本地服务器的 HTTP 请求

android - 在 Android 手机中启动图库

android - Google Analytics 回溯 Proguard

css - 将 css 与 title 和 rel 属性组合并最小化

java - Android java 应用程序上的 FFMPEG

Android 相机 API ISO 设置?

c# - 使相机应用程序适应屏幕旋转 - Windows Phone RT

android - 简单的 Android 相机应用程序 - 旋转导致 NullPointerException