Android URL Parse getUrlQueryParameters(final String url)

Here you can find the source of getUrlQueryParameters(final String url)

Description

get Url Query Parameters

Parameter

Parameter Description
url a parameter

Return

bundle that contains key-value entries of the url query.

Declaration

public static final Bundle getUrlQueryParameters(final String url) 

Method Source Code

//package com.java2s;

import java.net.URLDecoder;

import android.os.Bundle;

public class Main {
    /**//from www  .  j av  a 2 s.  com
     * 
     * @param url
     * @return bundle that contains key-value entries of the url query.
     */
    public static final Bundle getUrlQueryParameters(final String url) {
        final Bundle bundle = new Bundle();
        final String[] separated = url.split("\\?");
        if (separated.length > 1) {
            final String query = separated[1];
            final String[] params = query.split("&");
            for (final String param : params) {
                final String[] keyvalue = param.split("=");
                final String key = URLDecoder.decode(keyvalue[0]);
                String value = null;
                if (keyvalue.length > 1) {
                    value = URLDecoder.decode(keyvalue[1]);
                }
                bundle.putString(key, value);
            }
        }
        return bundle;
    }
}

Related

  1. getOrigin(String url)
  2. getParentUrl(String url)
  3. getRecentMediaUrl(String tag)
  4. getStringFromUrl(String url)
  5. getUrlContent(String urlStr)
  6. checkStringIsUrl(String input)
  7. hostFromUrl(String url)
  8. hasParameter(String url, String name)
  9. validateUrl(String url)