android - How to get the Uri path from a ImageView? -


i trying create wallpaper application. images come internet.

before of set background, need crop image. , this, using api named androidimagecropper. api need of uri object execute crop.

how can uri imageview? because image internet. image not on drawable folder. confusing. maybe guys can me.

public class mainactivity extends appcompatactivity {  private networkimageview imageview; private uri mcropimageuri; public static final string url_photo = "http://cdn.wonderfulengineering.com/wp-content/uploads/2016/02/iron-man-wallpaper-42-610x1084.jpg";  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      imageview = (networkimageview) findviewbyid(r.id.image_view);      // singleton volley api, load image internet     imageloader loader = mysingleton.getinstance(this).getimageloader();     loader.get(url_photo, imageloader.getimagelistener(imageview, r.drawable.temp_picture, android.r.drawable.ic_dialog_alert));      imageview.setimageurl(url_photo, loader);      // put image on uri object     // #################################     // ###    mcropimageuri =  <--   ###     // #################################  }  // action button public void cropimage(view view) {     // api crop image     cropimage.activity(mcropimageuri)             .start(this); } 

}

do have suggestion me? thanks.

so you're using volley? i'm not familiar volley, both of thoughts.

after image downloaded android device, try find absolute path of file , use android.net.uri.fromfile uri image.

or else, can use bitmap object directly, instead of uri.


ok, after investigation, think have 2 solutions.

  1. using volley download image file, without using imageloader. in way it's easy file uri of image.
  2. for android-image-cropper, can use activity or use view(refer here). can bitmap object of image in method onloadingcomplete of imageloadinglistener. use com.theartofdev.edmodo.cropper.cropimageview crop image.

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -