Android URL Parameter Get getValueFromQueryString(String url, String key)

Here you can find the source of getValueFromQueryString(String url, String key)

Description

get Value From Query String

Declaration

public static String getValueFromQueryString(String url, String key) 

Method Source Code

//package com.java2s;

public class Main {
    public static String getValueFromQueryString(String url, String key) {
        int keyStPos = url.indexOf(key + "=") + key.length() + 1;
        if (keyStPos == -1) {
            return "";
        }// ww w .j  av  a 2s.  c om
        int keyEnPos = url.indexOf("&", keyStPos);
        if (keyEnPos == -1) {
            keyEnPos = url.length();
        }
        return url.substring(keyStPos, keyEnPos);
    }

    public static int indexOf(String str, String searchStr) {
        if (str == null || searchStr == null) {
            return -1;
        }
        return str.indexOf(searchStr);
    }
}

Related

  1. paserParams(String url)
  2. getParamValue(String url, String param)
  3. parserURIQuery(String queryText)
  4. getQueryUrl(final String url)
  5. queryComponent(String url)