PHPサーバーに接続し、サーバーに保存されているデータベースからユーザー名パスワードを照合することにより、Androidアプリのログインアクティビティを作成しようとしています。ユーザーがドナーの場合はステートメント 1 を取得し、ユーザーが病院の場合は 0 を取得します。ただし、次のコードでは、結果が o であっても if ステートメントは常に else 部分の後に続きます。
ここに私のログインクラスがあります
login_hos.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String mUsername = username.getText().toString();
String mPassword = password.getText().toString();
tryLogin(mUsername, mPassword);
try {
if (!response.equals("Login Error !")&&(!response.equals("Connection Error !"))){
String arr[]=response.split(",");
String type=arr[1];
type.trim();
// String usr="donor";
if (type.equals("0")) {
Log.v("type", type);
Intent intent = new Intent(
getApplicationContext(),
HospitalHome.class);
intent.putExtra("user_name", arr[0]);
startActivity(intent);
}
else{
Log.v("type", type);
Intent intent = new Intent(getApplicationContext(),
DonorHome.class);
intent.putExtra("user_name", arr[0]);
startActivity(intent);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});