我試圖通過連接到PHP服務器和匹配來自數據庫的用戶名密碼存儲在服務器進行登錄活動我的Android應用程序的其他部分。如果用戶是捐獻者,則檢索陳述1,如果用戶是醫院,則檢索0。但是在下面的代碼中,if語句總是遵循else部分,即使結果是o。爲什麼我的if語句只運行在Android的
這裏是我的日誌類
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();
}
}
});
當您調試應用程序時什麼是「類型」(在'if' ???) –
在log cat處的值: - type = 0 – Chinthyfy
你確定它是0(數字零)vs「O」(字母'O')? (我只是猜測在這裏) –