package com.example.user.facefront;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Camera;
import android.graphics.ImageFormat;
import android.media.ImageReader;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.GLU;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.service.media.CameraPrewarmService;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.hardware.camera2.*;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.PictureCallback;
import java.io.IOException;
import java.security.PublicKey;
import java.util.Arrays;
import java.util.logging.LogRecord;
import java.util.logging.MemoryHandler;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
/**
* Created by user on 2016/2/1.
*/
@SuppressLint("NewApi")
public class camerafront extends Activity {
private SurfaceView surfaceView;
private SurfaceHolder holder;
private CameraManager manager;
private CaptureRequest.Builder builder;
private CameraDevice cameraDevice;
private HandlerThread handlerThread;
private Handler handler;
private ImageReader imageReader;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.camerafront);
manager=(CameraManager)getSystemService(Context.CAMERA_SERVICE);
surfaceView=(SurfaceView) findViewById(R.id.surfaceView);
holder=surfaceView.getHolder();
holder.setFixedSize(1280,960);
holder.addCallback(surfaceViewCallback);
}
private SurfaceHolder.Callback surfaceViewCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
handlerThread = new HandlerThread("HT");
handlerThread.start();
handler = new Handler(handlerThread.getLooper());
imageReader=ImageReader.newInstance(1280,960, ImageFormat.RGB_565,3);
try{
manager.getCameraIdList();
manager.openCamera("0", DeviceStateCallback, handler);
}catch (CameraAccessException e){
Log.e("CameraAccessException",e.getMessage());
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if(cameraDevice != null)
cameraDevice.close();
}
};
private CameraDevice.StateCallback DeviceStateCallback= new CameraDevice.StateCallback() {
@Override
public void onOpened(CameraDevice camera) {
try{
cameraDevice=camera;
builder.addTarget(holder.getSurface());
cameraDevice.createCaptureSession(Arrays.asList(holder.getSurface(),imageReader.getSurface()),CameraCaptureCallback,handler);
}catch (CameraAccessException e){
Log.e("CameraAccessException", e.getMessage());
}
}
@Override
public void onDisconnected(CameraDevice camera) {
}
@Override
public void onError(CameraDevice camera, int error) {
}
};
private CameraCaptureSession.CaptureCallback CameracaptureCallback = new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
super.onCaptureCompleted(session, request, result);
}
@Override
public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult) {
super.onCaptureProgressed(session, request, partialResult);
}
};
private CameraCaptureSession.StateCallback CameraCaptureCallback = new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(CameraCaptureSession session) {
try {
session.setRepeatingRequest(builder.build(), CameracaptureCallback,handler);
}catch (CameraAccessException e){
Log.e("CameraAccessException", e.getMessage());
}
}
@Override
public void onConfigureFailed(CameraCaptureSession session) {
}
};
}
如果我运行该程序,我将收到以下错误 错误:任务':app:processDebugManifest'执行失败。
Manifest合并失败,出现多个错误,请参阅日志
我不知道我收到此消息的原因,请帮助我
感谢。