String uriString = "https://example.com/path?id=123&name=John"; Uri uri = Uri.parse(uriString); String id = uri.getQueryParameter("id"); // returns "123" String name = uri.getQueryParameter("name"); // returns "John"
Uri uri = Uri.parse("https://example.com/auth?token=abc123"); String token = uri.getQueryParameter("token"); // returns "abc123"In this example, we create a Uri object directly from the URI string, and then use getQueryParameter to retrieve the value of the "token" parameter. Package library: android.net Overall, the Uri class in the android.net package provides a convenient and powerful way to parse and manipulate URIs in Android applications.