Reputation: 18501
Code:
Uri uri = Uri.parse("http://[7a03:908:671:b520:ba27:bbff:ffff:fed2]:1234")
Log.d("debug", uri.getPort()); // result: -1
getPort() returns -1 instead of 1234. How can the port of a Uri obtained without parsing the Uri's string?
Upvotes: 1
Views: 196
Reputation: 1524
I think it is a known bug in Android. android.net.Uri
returns incorrect values for IPv6. And it is still not fixed: https://issuetracker.google.com/issues/37069493
I think you have to parse it manually (at least for now)
Upvotes: 2