Uri uri = Uri.parse("https://www.example.com"); String scheme = uri.getScheme(); // returns "https" String host = uri.getHost(); // returns "www.example.com"
Uri.Builder builder = new Uri.Builder(); builder.scheme("https") .authority("www.example.com") .appendPath("path") .appendQueryParameter("param1", "value1") .appendQueryParameter("param2", "value2"); Uri uri = builder.build();This code uses the Uri.Builder class to construct a URI with the scheme "https", authority "www.example.com", path "/path", and query parameters "param1=value1" and "param2=value2". The build() method returns a Uri object representing the resulting URI. Package library: android.net