Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The only problem with APIs &lt; 11 is that this method is not implemented. I guess the best idea is to look into Android source code and use implementation from API >= 11. This should get you absolutely identic functionality even on older APIs.</p> <p>This one is from 4.1.1, modified to take Uri as a parameter, so you can use it right away:</p> <pre><code>/** * Returns a set of the unique names of all query parameters. Iterating * over the set will return the names in order of their first occurrence. * * @throws UnsupportedOperationException if this isn't a hierarchical URI * * @return a set of decoded names */ private Set&lt;String&gt; getQueryParameterNames(Uri uri) { if (uri.isOpaque()) { throw new UnsupportedOperationException("This isn't a hierarchical URI."); } String query = uri.getEncodedQuery(); if (query == null) { return Collections.emptySet(); } Set&lt;String&gt; names = new LinkedHashSet&lt;String&gt;(); int start = 0; do { int next = query.indexOf('&amp;', start); int end = (next == -1) ? query.length() : next; int separator = query.indexOf('=', start); if (separator &gt; end || separator == -1) { separator = end; } String name = query.substring(start, separator); names.add(Uri.decode(name)); // Move start to end of name. start = end + 1; } while (start &lt; query.length()); return Collections.unmodifiableSet(names); } </code></pre> <p>If you want to dig into it yourself, here is the original code:</p> <p><a href="http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/android/net/Uri.java?av=f">http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/android/net/Uri.java?av=f</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload