I'm trying to make a log in activity for my android app by connecting to the php server and matching the username password from database which is stored in the server. I retrieve statement 1 if the user is donor and 0 if the user is hospital. But in the following code the if statement always follow the else part even though the result is o.
here is my log in class
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???)responseis assigned?type.trim();where you should havetype = type.trim(). perhaps you have some extra whitespace.