Android URL Decode parseUrl(String url)

Here you can find the source of parseUrl(String url)

Description

parse Url

Declaration

public static Bundle parseUrl(String url) 

Method Source Code

//package com.java2s;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;

import android.os.Bundle;

public class Main {

    public static Bundle parseUrl(String url) {
        url = url.replace("rrconnect", "http");
        url = url.replace("#", "?");
        try {//  ww  w . j av a  2 s.c om
            URL u = new URL(url);
            Bundle b = decodeUrl(u.getQuery());
            b.putAll(decodeUrl(u.getRef()));
            return b;
        } catch (MalformedURLException e) {
            return new Bundle();
        }
    }

    public static Bundle decodeUrl(String s) {
        Bundle params = new Bundle();
        if (s != null) {
            params.putString("url", s);
            String array[] = s.split("&");
            for (String parameter : array) {
                String v[] = parameter.split("=");
                if (v.length > 1) {
                    params.putString(v[0], URLDecoder.decode(v[1]));
                }
            }
        }
        return params;
    }
}

Related

  1. decodeUrl(String s)
  2. decodeUrl(String s)
  3. decodeUrlFormEncoded(String data)
  4. parseForHTTP(String str)
  5. parseLastfmUrl(String url)
  6. parseUrl(String url)
  7. parserTrackURL(String trackURL)