我有一個登錄表單,並且在用戶輸入正確的用戶和密碼信息後,他們將被帶到一個歡迎表單。我不希望用戶先從應用程序的任何位置返回登錄表單,而無需先登錄。他們可以返回登錄表單的唯一方法是按回。我怎麼能阻止呢?通過按回不登錄表格
編輯: 以下是執行登錄的代碼。
private class UserLoginTask extends AsyncTask<String, Void, User> {
@Override
protected User doInBackground(String... params) {
User user;
try {
user = RestCommunicator.authenticateUser(params[0], params[1]);
} catch (NetworkException e) {
user = new User();
user.setResponseStatus("Network Error");
}
return user;
}
@Override
protected void onPostExecute(User result) {
if (result != null && result.getUsername() != null
&& !result.getResponseStatus().equals("Network Error")
&& !result.getResponseStatus().equals("wrong-user")
&& !result.getResponseStatus().equals("wrong-password")) {
Log.d("result", "*" + result.getResponseStatus() + "*");
userDao.insertOrReplace(result);
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
Editor editor = sharedPreferences.edit();
editor.putBoolean("loggedin", true);
editor.commit();
super.onPostExecute(result);
Intent intent = new Intent(SplashActivity.this,
WelcomeActivity.class);
startActivity(intent);
finish();
} else {
Intent intent = new Intent(SplashActivity.this,
LoginErrorActivity.class);
intent.putExtra("error", result.getResponseStatus());
startActivityForResult(intent, 90000);
}
}
}
你能發表一些代碼嗎? – Blackbelt