get Param From Url - Android Network

Android examples for Network:URL

Description

get Param From Url

Demo Code


//package com.java2s;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map<String, String> getParamFromUrl(String url) {
        Map<String, String> params = new HashMap<>();
        if (url != null) {
            String array[] = url.split("&");
            for (String parameter : array) {
                String v[] = parameter.split("=");
                try {
                    params.put(URLDecoder.decode(v[0], "UTF-8"),
                            URLDecoder.decode(v[1], "UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();

                }// w  w w  .ja v  a  2  s. co  m
            }
        }
        return params;
    }
}

Related Tutorials