我使用代码启动一个 Intent :
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
为什么如果 url 以“http”开头是有效的,但如果 url 以“HTTP”(大写)开头,它会抛出 ActivityNotFoundException?这很奇怪,因为 url 遵循标准 RFC 2396。
最佳答案
您可以使用:normalizeScheme()
//Return an equivalent URI with a lowercase scheme component.
// This aligns the Uri with Android best practices for intent filtering.
// For example, "HTTP://www.android.com" becomes "http://www.android.com"
Uri uri = Uri.parse(url).normalizeScheme()
startActivity(new Intent(Intent.ACTION_VIEW, uri))
在这里查看更多信息:normalizeScheme
关于android - 通过 Intent 启动浏览器,带有架构 "HTTP"(大写)错误的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27251456/