Android 安卓打开图片库
我正在尝试将图像打开到图库(或处理图像打开的任何其他应用程序) 问题是它告诉我它找不到元素。。。但是,调用BitmapFactory.decodeFile()时,图像已正确加载 这是密码Android 安卓打开图片库,android,android-intent,android-imageview,Android,Android Intent,Android Imageview,我正在尝试将图像打开到图库(或处理图像打开的任何其他应用程序) 问题是它告诉我它找不到元素。。。但是,调用BitmapFactory.decodeFile()时,图像已正确加载 这是密码 imgV = (ImageView)this.findViewById(R.id.image); final String path = myApp.getAppContext().getFilesDir().getPath().toString() + "/media/" + Tools.to
imgV = (ImageView)this.findViewById(R.id.image);
final String path = myApp.getAppContext().getFilesDir().getPath().toString() + "/media/" + Tools.toHexString(pmid) + "/" + md5 + ".jpg";
imgV.setImageBitmap(BitmapFactory.decodeFile(path));
imgV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file://" + path);
intent.setDataAndType(uri, "image/*");
startActivity(intent);
}
});
将您的图像保存到SD卡上具有全球可读权限的目录中,gallery将能够打开并显示图像
File folder = new File(Environment.getExternalStorageDirectory()+ "/myTmpDir/" + Tools.toHexString(pmid));
folder.mkdirs();
final String path = new File(Environment.getExternalStorageDirectory()+ "/myTmpDir/"+Tools.toHexString(pmid) + "/" + md5 + ".jpg");
imgV.setImageBitmap(BitmapFactory.decodeFile(path));
imgV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file://" + path);
intent.setDataAndType(uri, "image/*");
startActivity(intent);
}
});
md5的值在调用onClick时会改变吗?不,实际上,我已经创建了一个名为path的新变量。。。在decodeFile和uri.parse()上使用它,仍然相同。。。更新我的问题画廊对你活动的文件路径没有读取权限吗?@spartygw:怎么知道?如何授予权限?(我的文件在myApp数据文件夹中…)你能将adb shell放入其中并将目录修改为755吗?