简体   繁体   English

Uri getHost()返回null

[英]Uri getHost() returns null

I create Uri like this: 我这样创建Uri

Uri uri = Uri.parse(url);

Where url is http://www.YouthAgSummit.com 网址为http://www.YouthAgSummit.com

When I'm trying to get host from it I receive null. 当我尝试从中获取主机时,我收到null。 What is the problem? 问题是什么?

PS I'm trying to setup Intent-Filter for this Uri and ACTION_VIEW . PS我正在尝试为此UriACTION_VIEW设置Intent-Filter。

UPDATE Even for this one http://android.com/ from the docs I get null. 更新即使从文档的这个http://android.com/我也为空。

I solved this problem by using java.net.URI class instead of android.net.Uri . 我通过使用java.net.URI类而不是android.net.Uri解决了此问题。 They have same functionality for my needs (getting separate url parts like host, scheme etc.). 它们具有满足我需要的相同功能(获取单独的url部分,例如主机,方案等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM