Search code examples
androidandroid-camera-intent

When using the Camera app in Android, how can I return the whole image instead of just the thumbnail?


I am making an app that sends a picture taken from the Camera app however the image it returns seems to be only a thumbnail how can I get it to turn the whole image?

The following code gets an image, but it's too small.

public class OnTheJobActivity extends Activity{

 private static final int CAMERA_PIC_REQUEST = 1337;
 private Button takePictureButton;
 private Button sendPictureButton;
 private Bitmap thumbnail; 

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  this.setRequestedOrientation(
          ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  setContentView(R.layout.onthejob);
  takePictureButton = (Button) findViewById(R.id.takePictureButton);
  takePictureButton.setOnClickListener(takePictureButtonListener);
  sendPictureButton = (Button) findViewById(R.id.sendPictureButton);
  sendPictureButton.setOnClickListener(sendPictureButtonListener);


 }

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
     if (requestCode == CAMERA_PIC_REQUEST) {  
  thumbnail = (Bitmap) data.getExtras().get("data");  
  ImageView image = (ImageView) findViewById(R.id.photoResultView);  
  image.setImageBitmap(thumbnail);
  sendPictureButton.setVisibility(Button.VISIBLE);
     }  
 }  


 private OnClickListener takePictureButtonListener = new OnClickListener() {

  @Override
  public void onClick(View arg0){
      Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
      startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);  

  }
     };

     private OnClickListener sendPictureButtonListener = new OnClickListener() {

  @Override
  public void onClick(View arg0){

      Intent i = new Intent(Intent.ACTION_SEND);
      i.putExtra(Intent.EXTRA_EMAIL, "[email protected]");
      i.putExtra(Intent.EXTRA_SUBJECT,"On The Job");
      i.putExtra(Intent.EXTRA_STREAM, thumbnail);
      i.setType("image/bmp");
      startActivity(Intent.createChooser(i,"Emailfile"));

  }
     };


}

Solution

  • Try using the implementation shown here

    Specifically:

    Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
    
        public void onPictureTaken(byte[] imageData, Camera c) {
    
        }
    
    };