Reputation: 890
I'm trying to use the URI builder in Android to create a URL with variables. I have read Use URI builder in Android or create URL with variables, but some symbols that I need aren't covered in that.
An example of URL that I want to create:
I will want to substitute the ggscoord with a variable. I know how to append the path and query parameters... but what builder method should I use for the %7C and | ?
Upvotes: 2
Views: 1539
Reputation: 8528
Character like %7C
has been encoded,maybe it's a Chinese code or others,so if you want to add some parameters to your URL,just use URLEncoder.encode to encode your primitive string.
like this:
Uri.Builder builder = new Uri.Builder();
builder.scheme("http")
.authority("www.lapi.transitchicago.com")
.appendPath("api")
.appendPath("1.0")
.appendPath("ttarrivals.aspx")
.appendQueryParameter("key", "[redacted]")
.appendQueryParameter("mapid",URLEncoder.encode("&&&","UTF-8"); //note this
Upvotes: 5
Reputation: 580
In order to modify query, you may use appendQueryParameter for plain strings like "|", any you may use encodedQuery for pre-encoded strings like "%7C".
There is no append method for pre-encoded query parameters.
Upvotes: 5