1. Are you ready for the Galaxy S20? Here is everything we know so far!

send get request escapes symbols

Discussion in 'Android Development' started by acoolcoder, Apr 20, 2017.

  1. acoolcoder

    acoolcoder Lurker
    Thread Starter

    Hi guys, i try to send blood type of user. it is something in my country; 0 RH + so i can send 0 RH its fine (i can save it db) however +(positive) couldn't send. it is releted with get method beacuse we can't send special characters i guess.

    So is there any other way that i can send + positive or - negative symbols with get method.

    Code (Text):
    1. sending_url = "?blood="+blood_type;
    2. SendData send = new SendData();
    3. send.execute(sending_url);
    4. //send data
    5. URL url = new URL("http://....com/page.php"+url);
    6. HttpURLConnection con = (HttpURLConnection) url.openConnection();
    7. bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));

    #1 acoolcoder, Apr 20, 2017
    Last edited: Apr 20, 2017

    1. Download the Forums for Android™ app!


  2. Unforgiven

    Unforgiven ...eschew obfuscation...

    I put your code inside code tags to make it easier for the folks that understand that stuff to read. Good luck. :)
    Deleted User likes this.
  3. Deleted User

    Deleted User Guest

    Can you please show the code for the SendData.execute() method.
    acoolcoder likes this.
  4. acoolcoder

    acoolcoder Lurker
    Thread Starter

    Hi senddata my asynctask i put it bacground section. You see in my updated question.
  5. bayk

    bayk Member

  6. marcelpreda

    marcelpreda Member

    You have to encode the query string.
    Something like below should work:
    Code (Text):
    2. sending_url = "?blood="+ URLEncoder.encode(blood_type, "UTF-8");
    3. SendData send = new SendData();
    4. send.execute(sending_url);
    5. //send data
    6. URL url = new URL("http://....com/page.php"+url);
    7. HttpURLConnection con = (HttpURLConnection) url.openConnection();
    8. bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
    sweetndreemy73 likes this.

Share This Page