Prova classe HttpUrl
(nel pacchetto okhttp
).
//adds the pre-encoded query parameter to this URL's query string
addEncodedQueryParameter(String encodedName, String encodedValue)
//encodes the query parameter using UTF-8 and adds it to this URL's query string
addQueryParameter(String name, String value)
Nota: se vi sono già citarne accoppiamenti/valore con questo nome, queste funzioni è sufficiente aggiungere un altro paio
setEncodedQueryParameter(String encodedName, String encodedValue)
setQueryParameter(String name, String value)
Nota: se esistono già nome/valore coppie con questo nome, queste funzioni li rimuoveranno e solo dopo aggiungere questa nuova coppia
Esempio:
HttpUrl url = new HttpUrl.Builder()
.scheme("https")
.host("www.google.com")
.addPathSegment("search")
.addQueryParameter("q", "polar bears")
.build();
fonte
2015-08-21 18:17:11
aggiungere params a http entitiy. – KOTIOS