I am sending an intent for camera with a path in Extra. But in result i am not getting the image path. Where i am wrong?
my code is
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
if (!APP_FILE_PATH_Images.exists())
{
APP_FILE_PATH_Images.mkdirs();
}
Uri uriSavedImage =Uri.fromFile(new File(APP_FILE_PATH_Images+ File.separator +
"IMG_"+ getTimeStamp() + ".jpeg"));
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
onActivityResult code is:
else if(requestCode==CAMERA_REQUEST)
{
Uri selectedImage = data.getData();
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
cursor.moveToFirst();
final String filePath = cursor.getString(column_index);
Log.i("File path", filePath+"");
cursor.close();
runOnUiThread(new Runnable()
{
@Override
public void run()
{
imageData= new ImagesData();
imageData.Source= filePath;
imageData.isVector= false;
addImage(imageData);
}
});
}
I am able to get videos with the same code. Thanks,
You don't need to get the path back in the result: it would be the one you passed in. Try using that URI when your result comes back. (In other words, don't try to read it from the Intent, just save it locally.) It's not the same as capturing video. For more information, see: http://developer.android.com/training/camera/photobasics.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.