1
我试图让用户选择使用设备默认相机拍照并从图像库中选择也默认为设备。来自Gallery和Camera-taken-photo的URI/URL路径不同
我可以让相机拍照并将其显示在应用程序中,因为它似乎喜欢将URI路径直接传输到JPG文件。然而,给画廊URI的路径是非常不同的,根本不显示图像。
这里是pathes我得到:
当来自CAMERA的措施: /mnt/sdcard/filename.jpg
当来自画廊选择的范围: /外部/图像/媒体/ #(#为ID号/缩略图我相信)
用于检索二者pathes的代码是:
CAMERA:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
mImageCaptureUri =
Uri.fromFile(new file(Environment.getExternalStorageDirectory(),
"fname_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
画廊:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Complete action using"), PICK_FROM_FILE);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
随着画廊,它打开,我可以浏览就好了,它只是因为它与服用的确不显示图像图片。
用于图像拉进我的应用程序,一旦选定/采取的代码是:
ImageView getMyphoto = (ImageView) findViewById(R.id.usePhoto);
String stringUrl = prefSettings.getString("myPic", "");
Uri getIMG = Uri.parse(stringUrl);
getMyphoto.setImageURI(null);
getMyphoto.setImageURI(getIMG);
虐待这个试试看,谢谢。 – livingpaint