try
{
JSONObject obj =
new
JSONObject(s);
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
{
Toast.makeText(getApplicationContext(), obj.getString(
"message"
), Toast.LENGTH_LONG).show();
}