0
我想从/mnt/sdcard/img.jpg中将图像读入ImageView。Android:位图路径不正确
File image = new File(path);
Bitmap bm = BitmapFactory.decodeFile(image.getAbsolutePath());
webView1.setImageBitmap(bm);
我从图库中获取路径,我的应用说路径不存在。但在文件管理器中它是存在的。
我该如何解决?
if (arg0 == button4){
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
}
如何到映像文件的路径:
private String UriToBit(Uri uri) {
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(uri, proj, null, null, null);
int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(index);
}
你能过去错误描述吗? –