>我正在尝试从互联网下载图像并将其传递给设备的默认裁剪器,但它显示无法加载图像。
我的代码是:
Intent cropApps = new Intent("com.android.camera.action.CROP");
cropApps.setType("image/*");
List<ResolveInfo> list = this.getPackageManager().queryIntentActivities(cropApps, 0);
int size = list.size();
if (size == 0)
{
Toast.makeText(this, "Can not find image crop app", Toast.LENGTH_SHORT).show();
}
else
{
Uri picUri = Uri.parse("https://www.irononsticker.com/images/Doraemom43.jpg");
ResolveInfo res = list.get(0);
Intent cropIntent = new Intent();
cropIntent.setClassName(res.activityInfo.packageName, res.activityInfo.name);
cropIntent.setDataAndType(picUri, "image/*");
cropIntent.putExtra("outputX", 800);
cropIntent.putExtra("outputY", 800);
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
cropIntent.putExtra("scale", true);
cropIntent.putExtra("return-data", true);
startActivity(cropIntent);
您需要做的是转到文件,单击属性,然后复制位置。 示例:(r'C:\Users\Owner\Downloads\game\yourimagename.png'( 您注意到,粘贴位置后,输入"\"并单击所需的文件。
希望这有帮助