0

I'm getting an URISyntaxException exception while trying to do the following. I have absolutely no idea whats causing the issue. it would be nice to get some help. The error is located in the last line

    EditText edUserName = (EditText)findViewById(R.id.textBox_username_register);
    String strUsernameTemp = edUserName.getText().toString();
    byte[] byteUsernameTemp = null;
    try
    {
        byteUsernameTemp = strUsernameTemp.getBytes("UTF-8");
    }
    catch(UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }
    String strUsername = Base64.encodeToString(byteUsernameTemp, Base64.DEFAULT);

    EditText edPassword = (EditText)findViewById(R.id.passwordBox_password_register);
    String strPasswordTemp = edPassword.getText().toString();
    byte[] bytePasswordTemp = null;     
    try
    {
        bytePasswordTemp = strPasswordTemp.getBytes("UTF-8");
    }
    catch(UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }
    String strPassword = Base64.encodeToString(bytePasswordTemp, Base64.DEFAULT);       

    EditText edEmail = (EditText)findViewById(R.id.textBox_email_register);
    String strEmailTemp = edEmail.getText().toString();
    byte[] byteEmailTemp = null;
    try
    {
        byteEmailTemp = strEmailTemp.getBytes("UTF-8");
    }
    catch(UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }       
    String strEmail = Base64.encodeToString(byteEmailTemp, Base64.DEFAULT);     

    String strD = "22";
    String strM = "11";
    String strY = "1993";
    StringBuilder builder = new StringBuilder();
    HttpClient client = new DefaultHttpClient();        
    HttpGet httpget = new HttpGet(loginData.strAPIURL + "addUser&username=" + strUsername + "&password=" + strPassword + "&email=" + strEmail + "&d=" + strD + "&m=" + strM + "&y=" + strY); // this line causes the error
Sven Niehus
  • 487
  • 5
  • 24

1 Answers1

0

URISyntaxException is normally thrown if some info could not be parsed while creating the URI. Try encoding your URI using the URLEncoder.

String encodedURI = java.net.URLEncoder.encode(loginData.strAPIURL + "addUser&username=" + strUsername + "&password=" + strPassword + "&email=" + strEmail + "&d=" + strD + "&m=" + strM + "&y=" + strY,"UTF-8");
HttpGet httpget = new HttpGet(encodedURI);
Rajitha Siriwardena
  • 2,749
  • 1
  • 18
  • 22