Android URL Encode encodeUrl(Bundle parameters)

Here you can find the source of encodeUrl(Bundle parameters)

Description

encode Url

Declaration

public static String encodeUrl(Bundle parameters) 

Method Source Code

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

import java.net.URLEncoder;

import android.os.Bundle;

public class Main {
    public static String encodeUrl(Bundle parameters) {

        if (parameters == null) {
            return "";
        }//  www .j  ava  2s  .  c o  m

        try {

            StringBuilder sb = new StringBuilder();
            boolean first = true;
            for (String key : parameters.keySet()) {
                if (first)
                    first = false;
                else
                    sb.append("&");
                sb.append(URLEncoder.encode(key, "UTF-8")
                        + "="
                        + URLEncoder.encode(parameters.getString(key),
                                "UTF-8"));
            }
            return sb.toString();

        } catch (UnsupportedEncodingException e) {

            return "";
        }
    }
}

Related

  1. getURLEncodeStr(String url)
  2. getUrlCode(String pageUrl)
  3. urlEncode(String in)
  4. encode(String s)
  5. encodeParams(ArrayList params)
  6. encodeUriSegment(String segment)
  7. encodeUrl(Bundle parameters)
  8. encodeUrlParam(String s)
  9. weakUrlEncode(String url)