我正在发送带有额外路径的相机意图。但结果我没有得到图像路径。我哪里错了?
我的代码是
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 代码是:
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);
}
});
}
我可以使用相同的代码获取视频。谢谢,