2015-04-26 13 views

risposta

9

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(); 
Problemi correlati