从Web URL获取图像URI

时间:2016-06-06 16:22:19

标签: android uri

我正在使用Glide将图像从URL加载到ImageView中。我想从图像URL获得一个ImageURI。我能够生成一个普通的URI。但每当我将此URI传递给WallpaperManager getCropAndSetWallpaperIntent时,应用程序崩溃。

这是堆栈跟踪: -

Fatal Exception: java.lang.IllegalArgumentException: Image URI must be of the content scheme type
       at android.app.WallpaperManager.getCropAndSetWallpaperIntent(WallpaperManager.java:660)
       at backdoorstudio.polywallpapers.activity.MainActivity$1.onLongClick(MainActivity.java:138)
       at backdoorstudio.polywallpapers.adapters.GalleryAdapter$RecyclerTouchListener$1.onLongPress(GalleryAdapter.java:138)
       at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:690)
       at android.view.GestureDetector.access$200(GestureDetector.java:37)
       at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:266)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5234)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:70

这是我的代码获取URI: -

URL url = new URL(image.getLarge());  //     http://www.example.com/image_large.png
URI uri = url.toURI();

0 个答案:

没有答案