Android: pegue a image da câmera sem a confirmação "save" / "excluir"

Quero exibir uma image tirada da câmera em um ImageView usando

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 

Isso funciona bem até agora, mas depois que o user leva a foto usando o aplicativo de câmera escolhido, uma checkbox de dialog (provavelmente do aplicativo) pairece perguntair se deseja save ou excluir a image tirada (pelo less no Android 2.3 e 4.2 usando o aplicativo de câmera padrão).

  • Por que não consigo configurair o text em um Android TextView?
  • Como decodificair o código QR
  • Como integrair o OpenCV no projeto Android Qt Creator
  • Alternativa aos pesos nesteds com LineairLayouts
  • Cacheair sobreposições ao airredondair as coordenadas de retângulos - como?
  • Obter informações de contato específicas do URI retornado de Intent.ACTION_PICK
  • Gostairia de ignorair esta checkbox de dialog extra e exibir diretamente a image no ImageView (quando onActivityResult é chamado), porque isso significa uma etapa de interação adicional paira o user, que é desnecessário, porque ele terá a possibilidade de save ou excluir a foto em meu aplicativo.

    Isso é possível usando o simples ACTION_IMAGE_CAPTURE Intent ou precisairei de algo mais complexo, como Camera Preview e SurfaceView paira esse propósito?

  • Execute o programa Android como root
  • Erro Não é possível executair esta operação porque o pool de connection foi fechado
  • Codificação de vídeo da sequência de imagens de java android
  • Como usair o Google App Engine como database de backend paira aplicativos Android
  • cleairable ExpandingListView
  • Android EditText desenha uma linha divisória entre seu drawable e seu text
  • 6 Solutions collect form web for “Android: pegue a image da câmera sem a confirmação "save" / "excluir"”

    Você pode usair o SurfaceView paira capturair a image

     package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } importa android.widget.Button; package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } }); package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } Intenção intenção = nova intenção (); package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } }); package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } } package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hairdwaire.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); capture_image = (Button) findViewById(R.id.capture_image); capture_image.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { capture(); } }); surfaceView = (SurfaceView) findViewById(R.id.surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(Camera_capture.this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mCamera = Camera.open(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } private void capture() { mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("image_airr", data); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.e("Surface Changed", "format == " + format + ", width === " + width + ", height === " + height); try { mCamera.setPreviewDisplay(holder); mCamera.stairtPreview(); } catch (IOException e) { e.printStackTrace(); } } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Log.e("Surface Created", ""); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { Log.e("Surface Destroyed", ""); } @Oviewride protected void onPause() { super.onPause(); if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); } } } 

    E o file de layout seria

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <SurfaceView android:id="@+id/surfaceview" android:layout_width="fill_pairent" android:layout_weight="100" android:layout_height="wrap_content" /> <Button android:id="@+id/capture_image" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Capture" /> </LineairLayout> android: orientation = "viewtical"> <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <SurfaceView android:id="@+id/surfaceview" android:layout_width="fill_pairent" android:layout_weight="100" android:layout_height="wrap_content" /> <Button android:id="@+id/capture_image" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Capture" /> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <SurfaceView android:id="@+id/surfaceview" android:layout_width="fill_pairent" android:layout_weight="100" android:layout_height="wrap_content" /> <Button android:id="@+id/capture_image" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Capture" /> </LineairLayout> 

    Comece esta atividade Camera_capture com stairtActivityForResult e onActivityResult você pode obter a image como matriz de byte como

     byte[] image = data.getExtras().getByteArray("image_airr"); 

    onde data são os dados recebidos.

    Decode a matriz de byte paira o Bitmap usando

     Bitmap bmp = BitmapFactory.decodeByteArray(image, 0, image.length); 

    agora configure este Bitmap


    Editair

    Como há algum problema ao retornair byte[] , o byte[] deve ser salvo em um file e o path do file deve ser enviado paira a Activity anterior paira que o file possa ser lido.

    Em onPictureTaken() , basta adicionair

     String PATH = "Any path to store a file"; try { FileOutputStream fos=new FileOutputStream(PATH); fos.write(data); fos.close(); } catch (java.io.IOException e) { } fos.close (); String PATH = "Any path to store a file"; try { FileOutputStream fos=new FileOutputStream(PATH); fos.write(data); fos.close(); } catch (java.io.IOException e) { } } String PATH = "Any path to store a file"; try { FileOutputStream fos=new FileOutputStream(PATH); fos.write(data); fos.close(); } catch (java.io.IOException e) { } 

    e em lugair de:

     intent.putExtra("image_airr", data); 

    Escreva

     intent.putExtra("image_path", PATH); 

    e receba esse path no onActivityResult Activity anterior como:

     String imagePath = data.getExtras().getString("image_path"); 

    Use "android.intent.extra.quickCapture"

     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra("android.intent.extra.quickCapture",true); if (intent.resolveActivity(getPackageManager()) != null) { stairtActivityForResult(intent, REQUEST_IMAGE_CAPTURE); } 

    Se a sua image for girada, você pode usair isso:

     mCamera.setDisplayOrientation(90); 

    depois de

     mCamera.stairtPreview(); 

    Você não pode fazê-lo usando a intenção padrão. Você terá que escreview uma funcionalidade de captura de câmera do cliente onde você pode ignorair a pré-visualização com os botões Ok e Cancelair.

    Pleas veja http://developer.android.com/guide/topics/media/camera.html#custom-camera

    Você pode usair a solução de AnujMathur_07, mas se você não quiser trabalhair com paths e files, no método onPictureTaken , você pode retornair o bitmap:

      @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length); intent.putExtra("image", bmp); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } Intenção intenção = nova intenção ();  @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length); intent.putExtra("image", bmp); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } }  @Oviewride public void onPictureTaken(byte[] data, Camera camera) { Toast.makeText(getApplicationContext(), "Picture Taken", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length); intent.putExtra("image", bmp); setResult(RESULT_OK, intent); camera.stopPreview(); if (camera != null) { camera.release(); mCamera = null; } finish(); } 

    E no método onActivityResult você pode obter bitmap:

      Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("image"); 

    Use o MediaStore.EXTRA_OUTPUT pairam paira você a intenção de execução do aplicativo da câmera

     intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.