我正在设计一个Android应用程序,但问题是它没有显示用户找不到登录页面,或者没有显示密码是否错误我使用此代码。
String ip = sharedpreferences.getString("ip", "");
HttpPost httppost = new HttpPost("http://"+ip+":8080/HibernateWebApp/register");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("signInOrUp", "1"));
nameValuePairs.add(new BasicNameValuePair("userName", user
.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("password1", pass
.getText().toString()));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
try {
HttpResponse response = httpclient.execute(httppost);
String jsonString = inputStreamToString(
response.getEntity().getContent()).toString();
if (jsonString.equalsIgnoreCase("f")) {
Intent i = new Intent(getBaseContext(),
ScanActivity.class);
startActivity(i);
LoginActivity.this.finish();
} else {
Toast.makeText(LoginActivity.this,
"User not Found", Toast.LENGTH_LONG)
.show();
}
这是错误密码的一部分
if (jsonString.equalsIgnoreCase("f")) {
Intent i = new Intent(getBaseContext(),
ScanActivity.class);
startActivity(i);
LoginActivity.this.finish();
} else {
Toast.makeText(LoginActivity.this,
"User not Found", Toast.LENGTH_LONG)
.show();
}