1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  private void takePhoto() {
    
    i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    Uri mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "file.jpg"));
    i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
    i.putExtra("return-data", true);
        startActivityForResult(i, cameraData);
  }

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode == RESULT_OK) {
      Bundle extras = data.getExtras();
      path = getLastImagePath();
      file = new File(path);
      String[] separated = path.split("/");
      filename = separated[separated.length-1];
      
      bmp = (Bitmap) extras.get("data");
      iv.setImageBitmap(bmp);
      
      
    }
    else 
      takePhoto();
  }