【发布时间】:2018-05-29 06:58:45
【问题描述】:
我想让登录按钮使用数据库上的标志列分派到 2 个不同的活动中??
如果租户登录,它将重定向到租户活动
当房东登录时,它会重定向到其他活动吗?
public void onResponse(String response) {
Log.e(TAG, "Register Response: " + response.toString());
hideDialog();
try {
JSONObject jObj = new JSONObject(response);
success = jObj.getInt(TAG_SUCCESS);
// Check for error node in json
if (success == 1) {
String username = jObj.getString(TAG_USERNAME);
String id = jObj.getString(TAG_ID);
Log.e("Successfully Login!", jObj.toString());
Toast.makeText(getApplicationContext(), jObj.getString(TAG_MESSAGE), Toast.LENGTH_LONG).show();
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(session_status, true);
editor.putString(TAG_ID, id);
editor.putString(TAG_USERNAME, username);
editor.commit();
// go to main activity
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra(TAG_ID, id);
intent.putExtra(TAG_USERNAME, username);
finish();
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(),
jObj.getString(TAG_MESSAGE), Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
// JSON error
e.printStackTrace();
}
}
【问题讨论】:
-
您可以根据条件添加if语句并在其中使用intent
-
java? php?请不要标记垃圾邮件
-
@DheerajJoshi 我应该在哪里以及什么条件下使用它??
标签: java php mysql android-studio android-volley