try {
//converting response to json object
JSONObject obj = new JSONObject(s);
//if no error in response
if (!obj.getBoolean("error")) {
String username = obj.getString("username");
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(USERNAME, username);
editor.putString(EMAIL, email);
editor.putBoolean(STATUS, true);
editor.apply();
sharedPreferences = getSharedPreferences(MY_PREFERENCES, Context.MODE_PRIVATE);
if(USERNAME == "cha"){
finish();
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_LONG).show();
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
startActivity(intent);
}else {
finish();
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_LONG).show();
Intent intent = new Intent(LoginActivity.this, SelectActivity.class);
startActivity(intent);
}
}
else{
//finish();
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_LONG).show();
//Intent intent = new Intent(LoginActivity.this, LoginActivity.class);
// startActivity(intent);
}
USERNAME의 값은 cha의 내용의 값을 가지고 있는 것을 확인 하였고,
USERNAME에 있는 값과 "cha"를 비교해서 RegisterActivity와 SelectActivity로 구분하여 가동 하려 하였으나 SharedPreferences의 사용법에 문제가 있는것 같습니다, 현재 문제는 if문에 else에만 걸려 SelectActivity만 열리는 문제 입니다 ..ㅠㅠ 선생님 답변 부탁드립니다...ㅜㅜ