无法访问Android Galaxy S3上的前置摄像头
我有一个小应用程序,我一直在工作,使用前摄像头。我使用前置摄像头的方式似乎适用于大多数手机,但用户一直在报告S3和其他各种新设备出现故障。我访问前置摄像头的方式如下:无法访问Android Galaxy S3上的前置摄像头,android,camera,galaxy,samsung-mobile,Android,Camera,Galaxy,Samsung Mobile,我有一个小应用程序,我一直在工作,使用前摄像头。我使用前置摄像头的方式似乎适用于大多数手机,但用户一直在报告S3和其他各种新设备出现故障。我访问前置摄像头的方式如下: // Find the ID of the front camera CameraInfo cameraInfo = new CameraInfo(); for(int i = 0; i < numberOfCameras; i++) { Camera.getCamer
// Find the ID of the front camera
CameraInfo cameraInfo = new CameraInfo();
for(int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if(cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
defaultCameraId = i;
mCameraFound = true;
}
}
if(!mCameraFound)
displayDialog(8);
restartPreview调用是对相同(但不同)方法的调用。从我通过用户收集的一些调试数据中,我注意到应用程序在S III上找到了两个摄像头,并选择了与前面摄像头匹配的id。而且,这个问题似乎并不是发生在所有的S III上。我有一些用户也有同样多的反馈报告。遇到此问题的用户的最新报告是AT&T S III用户。任何帮助都将不胜感激 今晚有一个S3遇到了我的应用程序的这个问题。这里发生了什么。TextureView依赖于2d硬件加速,默认情况下(据我所知)在4.0+设备上应该启用2d硬件加速。他的手机上没有开机(至少我的应用程序是这样)。修复过程非常简单,只需在清单中添加一行(在应用程序下)
它对我的机器人Razr Maxx有效。不管怎样,你能在设置相机预览的地方张贴代码吗?问题可能出在这段代码中。我有一个摄像头应用程序,我的应用程序在这方面的行为不一致。这个问题可能与您使用S3选项保持屏幕活动有关,如果您正在查看它?该功能使用前摄像头!
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
try {
if (mCamera != null) {
Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(mPreviewSize.height, mPreviewSize.width);
requestLayout();
mCamera.setParameters(parameters);
mCamera.setPreviewTexture(surface);
mCamera.startPreview();
}
}
catch(RuntimeException e) {
// Log.e(TAG, "RuntimeException caused by setPreviewTexture()", exception);
}
catch (IOException e) {
// Log.e(TAG, "IOException caused by setPreviewTexture()", exception);
}
}
android:hardwareAcceleration = "true"