如何将android.net.Uri转换为java.net.URL? [英] How to convert android.net.Uri to java.net.URL?

查看:158
本文介绍了如何将android.net.Uri转换为java.net.URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将 Uri 转换为网址?我需要这个我正在使用的库,接受 URL 但我需要在我的设备上使用图像。

Is there a way to convert from Uri to URL? I need this for a library I'm using, it only accepts an URL but I need to use an image on my device.

推荐答案

如果 Uri 的方案是 http https 新网址(uri.toString())应该有效。

If the scheme of the Uri is http or https, new URL(uri.toString()) should work.

如果 Uri 的方案是 file ,那可能仍然我也很紧张。

If the scheme of the Uri is file, that may still also work, though I get nervous.

如果 Uri 的方案是 ftp jar ,这可能仍然有用,但我们想知道为什么你有一个 Uri 使用这些方案。

If the scheme of the Uri is ftp or jar, that may still also work, though we will wonder why you have a Uri with those schemes.

如果 Uri 的方案是其他任何内容—例如 content —这不起作用,你需要找到一个更好的库。

If the scheme of the Uri is anything else — such as content — this will not work, and you need to find a better library.

这篇关于如何将android.net.Uri转换为java.net.URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆