相机preVIEW是后屏幕关闭,屏幕上全黑 [英] Camera preview is completely black after screen off, screen on

查看:142
本文介绍了相机preVIEW是后屏幕关闭,屏幕上全黑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟在API演示相机preVIEW自带的Andr​​oid SDK的工作。当摄像机preVIEW正在运行,如果我关掉我的屏幕,并再次打开,相机preVIEW完全是黑色的。该设备的摄像头应用程序以某种方式设法恢复相机preVIEW,所以必须有一种方式。

I'm working with the CameraPreview in the API Demos that comes with the Android SDK. While the camera preview is running, if I turn off my screen and turn it on again, the camera preview is completely black. The device's camera application somehow manages to restore the camera preview, so there must be a way.

不是我试图表现出这种行为的所有设备。我无法证实,但它似乎是操作系统版本的问题。

Not all devices I've tried exhibit this behavior. I can't confirm, but it seems like the OS version matters.

推荐答案

什么帮助我是的setContentView()在onResume()。

What helped me was setContentView() in onResume().

它可以是

protected void onResume() {
    super.onResume();
    setContentView(R.layout.xxx);
    // ...
}

private View cachedContentView;
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    cachedContentView = doCreateContentView(getLayoutInflater());
    // ...
}
protected void onResume() {
    super.onResume();
    setContentView(cachedContentView);
    // ...
}

他们两人的工作。

Both of them work.

这篇关于相机preVIEW是后屏幕关闭,屏幕上全黑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆