尝试执行以下操作时,我收到了URISyntaxException异常。我完全不知道是什么造成了这个问题。得到一些帮助会很高兴。错误位于最后一行
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
答案 0 :(得分:0)
URISyntaxException
。尝试使用URI
对您的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);