List of usage examples for android.view SurfaceHolder setType
@Deprecated public void setType(int type);
From source file:org.artoolkit.ar.utils.calib_optical.CameraSurface.java
@SuppressWarnings("deprecation") public CameraSurface(Context context) { super(context); Log.i(TAG, "CameraSurface(): ctor called"); Activity activityRef = (Activity) context; try {/*from w ww . j a va 2s .c om*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activityRef, Manifest.permission.CAMERA)) { mustAskPermissionFirst = true; if (activityRef.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) { // Will drop in here if user denied permissions access camera before. // Or no uses-permission CAMERA element is in the // manifest file. Must explain to the end user why the app wants // permissions to the camera devices. Toast.makeText(activityRef.getApplicationContext(), "App requires access to camera to be granted", Toast.LENGTH_SHORT).show(); } // Request permission from the user to access the camera. Log.i(TAG, "CameraSurface(): must ask user for camera access permission"); activityRef.requestPermissions(new String[] { Manifest.permission.CAMERA }, calib_optical_Activity.REQUEST_CAMERA_PERMISSION_RESULT); return; } } } catch (Exception ex) { Log.e(TAG, "CameraSurface(): exception caught, " + ex.getMessage()); return; } SurfaceHolder holder = getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10. }
From source file:com.TwentyCodes.android.IOIOTruck.CameraFragment.java
/** * (non-Javadoc)//from w w w . j a va 2s. c om * @see android.support.v4.app.Fragment#onViewCreated(android.view.View, android.os.Bundle) * @author ricky barrette */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.camera_fragment, container, false); /* * setup augmented preview overlay */ FrameLayout fl = (FrameLayout) view.findViewById(R.id.camera_frame); mPreviewOverlay = new PreviewOverlay(this.getActivity()); fl.addView(mPreviewOverlay); /* * setup camera preview */ mPreview = (SurfaceView) view.findViewById(R.id.cameraSurface); SurfaceHolder cameraHolder = mPreview.getHolder(); cameraHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); cameraHolder.addCallback(new SurfaceHolder.Callback() { public void surfaceCreated(SurfaceHolder holder) { try { mCamera.setPreviewDisplay(holder); mCamera.startPreview(); } catch (IOException e) { e.printStackTrace(); } } public void surfaceDestroyed(SurfaceHolder holder) { } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } }); return view; }
From source file:com.kupay.decoder.DecoderActivity.java
public void startCamera() { //(SurfaceView) getView().findViewById(R.id.preview_view); RelativeLayout rl = (RelativeLayout) getView().findViewById(R.id.fitCamera); surfaceView = new SurfaceView(getActivity()); SurfaceHolder surfaceHolder = surfaceView.getHolder(); Log.v("app", "Cargando camara"); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); if (rl != null && surfaceView != null) rl.addView(surfaceView);//from w ww.j a va 2 s. c o m }
From source file:org.artoolkit.ar.base.camera.CaptureCameraPreview.java
/** * Constructor takes a {@link CameraEventListener} which will be called on * to handle camera related events./*from w ww.j av a 2 s. c om*/ * * @param cel CameraEventListener to use. Can be null. */ @SuppressWarnings("deprecation") public CaptureCameraPreview(Activity activity, CameraEventListener cel) { super(activity); Log.i(TAG, "CaptureCameraPreview(): ctor called"); try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA)) { mustAskPermissionFirst = true; if (activity.shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) { // Will drop in here if user denied permissions access camera before. // Or no uses-permission CAMERA element is in the // manifest file. Must explain to the end user why the app wants // permissions to the camera devices. Toast.makeText(activity.getApplicationContext(), "App requires access to camera to be granted", Toast.LENGTH_SHORT).show(); } // Request permission from the user to access the camera. Log.i(TAG, "CaptureCameraPreview(): must ask user for camera access permission"); activity.requestPermissions(new String[] { Manifest.permission.CAMERA }, REQUEST_CAMERA_PERMISSION_RESULT); return; } } } catch (Exception ex) { Log.e(TAG, "CaptureCameraPreview(): exception caught, " + ex.getMessage()); return; } SurfaceHolder holder = getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Deprecated in API level 11. Still required for API levels <= 10. setCameraEventListener(cel); }
From source file:com.abhi.barcode.fragment.BarCodeFragment.java
@Override public void onResume() { super.onResume(); if (runCamera && hasSurface) { startCameraCampure();/*from ww w . j ava2 s. c o m*/ } else if (runCamera) { SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.cameraView); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(BarCodeFragment.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } }
From source file:com.abhi.barcode.fragment.BarCodeFragment.java
public void startCameraCampure() { cameraManager = new CameraManager(getActivity().getApplicationContext()); viewfinderView.setCameraManager(cameraManager); handler = null;/* w ww .j ava 2 s .c o m*/ resetStatusView(); runCamera = true; SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.cameraView); SurfaceHolder surfaceHolder = surfaceView.getHolder(); hasSurface = true; if (hasSurface) { initCamera(surfaceHolder, viewfinderView); } else { surfaceHolder.addCallback(BarCodeFragment.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } decodeFormats = null; characterSet = null; cameraActive = true; }
From source file:com.jwetherell.QRComm575.DecoderActivity.java
@Override protected void onResume() { super.onResume(); Log.v(TAG, "onResume()"); // CameraManager must be initialized here, not in onCreate(). if (cameraManager == null) cameraManager = new CameraManager(getApplication()); if (viewfinderView == null) { viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); }/*from w w w . java 2 s.c o m*/ showScanner(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } }
From source file:com.jwetherell.quick_response_code.DecoderActivity.java
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). if (cameraManager == null) { cameraManager = new CameraManager(getApplication()); }//from ww w .j a v a2s . c o m if (viewfinderView == null) { viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); } showScanner(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } }
From source file:com.agiro.scanner.android.CaptureActivity.java
@Override protected void onResume() { super.onResume(); resetStatusView();//w ww . j ava 2s . com Log.d(TAG, "onResume"); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } }
From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java
@SuppressWarnings("deprecation") @Override//from ww w . j a v a 2 s . co m public void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). This is // necessary because we don't // want to open the camera driver and measure the screen size if we're // going to show the help on // first launch. That led to bugs where the scanning rectangle was the // wrong size and partially // off screen. cameraManager = new CameraManager(this.getActivity(), getView()); viewfinderView.setCameraManager(cameraManager); handler = null; resetStatusView(); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } ambientLightManager.start(cameraManager); inactivityTimer.onResume(); characterSet = null; }