두 개의 텍스트 박스와 체크 박스가 있습니다. 하지만 내 사용자 이름과 암호를 입력하고 checkmebox에 체크 표시를하면 응용 프로그램을 끝내고 다시 돌아갑니다. 왜?로그인 정보 기억 기능 로그인시
// Get reference to UI elements
txtLogin = (EditText) findViewById(R.id.txtLogin);
txtPassword = (EditText) findViewById(R.id.txtPassword);
SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);
String username = pref.getString(PREF_USERNAME, null);
String password = pref.getString(PREF_PASSWORD, null);
if (username == null || password == null) {
//Prompt for username and password
Toast.makeText(getBaseContext(),
"HI",
Toast.LENGTH_SHORT).show();
}
// Remember me function
CheckBox cbRemember = (CheckBox) findViewById(R.id.chkRememberPassword);
if (cbRemember.isChecked()) {
getSharedPreferences(PREFS_NAME,MODE_PRIVATE)
.edit()
.putString(PREF_USERNAME, txtLogin.toString())
.putString(PREF_PASSWORD, txtPassword.toString())
.commit();
}
얻을 수 있습니까? – kaspermoerch