【发布时间】:2017-06-21 11:11:19
【问题描述】:
- 列表项
我有一个现有的应用程序市场版本,可以与所有其他 android 版本一起正常工作。但最近我注意到我的应用程序的图像上传功能(通过图库和相机)在我的手机上不起作用(最近升级到 Nougat)。在调试时,我注意到代码在以下点中断
ExifInterface exif = new ExifInterface(uriImage.toString());
虽然 uriImage 似乎有一个有效的 url。 (价值 我通过执行 new File(uriImage.toString()) 确认了这一点,它似乎工作正常。 此时uriImage.toString()的值为..
我已经在互联网上搜索过,但没有找到任何结果。虽然我怀疑下面链接中解释的牛轧糖行为。我已经按照作者的建议进行了更改,但问题仍然存在。下面是我触发相机/选择器意图的代码
public static Uri startChooseImage(Activity parent, String tag, String message, boolean useCamera, int requestId)
{
Uri uriImage = FileProvider.getUriForFile(parent,
"com.dyt.fileprovider",
new File(
Environment.getExternalStorageDirectory() + File.separator + tag));
/* Uri uriImage = Uri.fromFile(new File(
Environment.getExternalStorageDirectory() + File.separator + tag));*/
Intent selIntent = new Intent("android.intent.action.PICK").setType("image/*");
selIntent.setFlags(FLAG_GRANT_READ_URI_PERMISSION);
selIntent.setFlags(FLAG_GRANT_WRITE_URI_PERMISSION);
Intent chooserIntent = Intent.createChooser(selIntent, message);
if (useCamera) {
List<Intent> intentsList = new ArrayList();
Intent camIntent = new Intent("android.media.action.IMAGE_CAPTURE");
camIntent.setFlags(FLAG_GRANT_READ_URI_PERMISSION);
camIntent.setFlags(FLAG_GRANT_WRITE_URI_PERMISSION);
PackageManager pm = parent.getPackageManager();
List<ResolveInfo> listCam = pm.queryIntentActivities(camIntent, 0);
for (ResolveInfo res : listCam) {
Intent finalIntent = new Intent(camIntent);
finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
finalIntent.putExtra("output", uriImage);
intentsList.add(finalIntent);
}
chooserIntent.putExtra("android.intent.extra.INITIAL_INTENTS",
(Parcelable[])intentsList.toArray(new Parcelable[intentsList.size()]));
}
parent.startActivityForResult(chooserIntent, requestId);
return uriImage;
}
有人可以帮我解决这个问题吗?
【问题讨论】:
-
uriImage.toString()。请说出它的价值。 -
您的帖子中没有上传代码,也没有使用exif接口cide行的代码。
-
code breaks in the below point。什么是“代码中断”? -
“虽然 uriImage 似乎有一个有效的 url”——平台
ExifInterface(你不应该使用)或支持库ExifInterface在构造函数中都没有获取 URL 值。
标签: android android-intent android-file android-7.0-nougat android-fileprovider