how to handle camera intent android

2019-07-23 22:25发布

问题:

I was working on some camera stuff in android and i get some tutorials.

For my needs i get the following code to be used:

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

But using this when i capture the image, this Intent automatically stores the Image in my SD CARD. but i dont want it to store it to my SD CARD because i am storing that image to some other place/folder in SD Card. So is it possible in here that i can stop this intent to store the image into SDCard automatically.

Please Friends Help

回答1:

use this . It will save the image to any myfolder in your SDCard.

String imageFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/myfolder/myfavoritepicture.jpg";
File imageFile = new File(imageFilePath);
Uri imageFileUri = Uri.fromFile(imageFile);
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
startActivityForResult(i, CAMERA_RESULT);