gpt4 book ai didi

android - 将 java.net.URI 转换为 android.net.Uri

转载 作者:IT王子 更新时间:2023-10-28 23:37:03 24 4
gpt4 key购买 nike

我能够找到如何将 android.net.Uri 转换为 Java.net.URI here但反之亦然。

所以在花了一些时间后,我想通了。这是解决方案(如果有其他解决方案,请同时发布)

先将javaURI转成字符串,然后使用android.net.Uri的解析函数

android.net.URI androidUri = android.net.Uri.parse(javaURI.toString());

最佳答案

http://developer.android.com/reference/android/net/Uri.html#parse(java.lang.String)

public static Uri parse (String uriString)

Creates a Uri which parses the given encoded URI string.

Parameters
uriString: an RFC 2396-compliant, encoded URI

Returns
Uri for this given uri string

Throws
NullPointerException if uriString is null


因此,这里是一个例子:

android.net.Uri.parse(new java.net.URI("").toString());

不用说,用真正的 java.net.URI 里面... ;)

关于android - 将 java.net.URI 转换为 android.net.Uri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12649530/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com