我正在尝试通过调用显示相机拍摄的已保存图片的路径
`data.getdata`
在 Toast 中,但应用程序崩溃。我也试过data.getDataString
但没有解决
任何事物。
代码:
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent imageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "My Images");
imagesFolder.mkdirs();
File image = new File(imagesFolder, "img01");
Uri uriSavedImage = Uri.fromFile(image);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
startActivityForResult(imageIntent,CAMERA_REQUEST_CODE);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if ((requestCode == CAMERA_REQUEST_CODE) && (resultCode == RESULT_OK)) {
Toast.makeText(getApplicationContext(), "Image Saved To: "+data.getData(), Toast.LENGTH_SHORT).show();
}