1

Saw the solution, but I once worked, once not been online. I do not know what is.

   int resultCode = -1, Intent data = null

Take photos and often get.

private void takePicture() {
        Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        File photoFile = new File(Environment.getExternalStorageDirectory(), StartMenuActivity.DIR_NAME + "/" + travelDirName
                + "/" + travelDirName + "_" + poisArray.size() + ".jpg");
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));

        imageOrVideoUri = Uri.fromFile(photoFile);

        startActivityForResult(cameraIntent, CAMERA_REQUEST_PICTURE);
    }


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if ((resultCode == RESULT_OK)&&(data != null)) {
            if (requestCode == CAMERA_REQUEST_PICTURE) {
                createThumbnail();
                addPoi(PICTURE_POI);
            }
            if (requestCode == CAMERA_REQUEST_VIDEO) {
                addPoi(VIDEO_POI);
            }
            // Uri selectedUri = imageOrVideoUri;
            // Bitmap photo = (Bitmap) data.getExtras().get("data");
            // imageView.setImageBitmap(photo);
        } else {
            Toast.makeText(TravelMapActivity.this, R.string.poi_add_error, Toast.LENGTH_LONG).show();
        }
}

How to fix? thanks.

JDev
  • 2,157
  • 3
  • 31
  • 57

2 Answers2

0

try this,

protected void TakePhoto() {

        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");

        File photo = new File(Environment.getExternalStorageDirectory()
                + "/LiveChat", "IMG_temp.jpg");
        System.gc();
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
        imageUri = Uri.fromFile(photo);
        startActivityForResult(intent, 1);

}

  protected void onActivityResult(int requestcode, int resultcode, Intent data) {

        if (resultcode == RESULT_OK) {
            System.gc();
            switch (requestcode) {
            case 0:

         //ADD YOUR STUFF
                    }

        } else {
            Toast.makeText(getApplicationContext(), "No Image Selected",
                    Toast.LENGTH_SHORT).show();
        }

}
MuraliGanesan
  • 3,233
  • 2
  • 16
  • 22
0

So, the problem here is that you are specifying the URI to write the photo to in your camera intent. If you provide a URI, the default functionality is to not provide the thumbnail - because you already know the location of the image. In your activity result, just use the URI to retrieve your image. There are a couple of related posts on this issue.

Community
  • 1
  • 1
Submersed
  • 8,810
  • 2
  • 30
  • 38