0

I'm trying to download an image from internet and pass it to the device's default cropper but it's showing can't load image.

My code is:

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);
Poger
  • 1,897
  • 18
  • 16
Srinivas Nahak
  • 1,846
  • 4
  • 20
  • 45
  • [Android does not have a `CROP` `Intent`](http://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html). There are many [image cropping libraries for Android](https://android-arsenal.com/tag/45). Please use one. – CommonsWare Jul 11 '17 at 16:18
  • I agree, I use picasso for this things and works like a charm. – jeprubio Jul 11 '17 at 16:22
  • Sir can you please share your code with me @jeprubio – Srinivas Nahak Jul 11 '17 at 16:34
  • It's easy to find, have a look at the answer in here: https://stackoverflow.com/questions/43281758/crop-image-as-square-with-picasso – jeprubio Jul 11 '17 at 16:38

1 Answers1

-1

what you need to do is go to the file, click properties, and copy the location. example: (r'C:\Users\Owner\Downloads\game\yourimagename.png') you notice that after you paste the loctation, put a '\' and click on the file you want.

hope this helps

Cool Ninja
  • 23
  • 3
  • 1
    Hello and welcome to StackOverflow! I'm sure you wanted to help but I believe this isn't really what the author had in mind. If you take a closer look then it seems that the image should be downloaded from a specific URI and not loaded from a system file. Please, consider updating your answer to make it more helpful. If you don't know the answer to the question then please consider removing it. Cheers! – Poger Aug 28 '18 at 19:40