인증 샘플을 사용하여 Android 4.2에 인증 시스템을 구현하고 있습니다. 내 응용 프로그램에는 MenuActivity가 로그인 옵션과 함께 있습니다. 이 옵션을 클릭하고 사용자가 이미 로그인되어 있지 않으면 인증 시스템이 시작되고 AuthenticationActivity가 표시됩니다.Android 인증 : 콜백이 호출되지 않았습니다.
로그인이 끝나면 MenuActivity에서 일부 코드를 실행하여 사용자가 로그인했음을 알 수 있습니다. 이렇게하려면 콜백을 만들었지 만 결코 호출되지 않습니다. 로그인은 내가 응용 프로그램을 닫고 다시 시작하면 로그인으로 사용자를 감지, 잘 작동
내 메뉴 활동에서 나는이 있습니다. (LoginActivity라고합니다) 내 AuthenticatorActivity에서
public void login() {
if(mAccount != null)
Toast.makeText(MenuActivity.this, getString(R.string.account_exists), Toast.LENGTH_LONG).show();
else{
mAccountManager.addAccount(ACCOUNT_TYPE, AUTHTOKEN_TYPE, null, null, this, completeCallbackLogin, null);
}
}
// Callback called when the login ends.
private AccountManagerCallback<Bundle> completeCallbackLogin = new AccountManagerCallback<Bundle>() {
public void run(AccountManagerFuture<Bundle> arg0) {
Log.d("MenuActivity", "CALLBACK");
// When the login ends we save the account in the global variables
refreshAccount();
Toast.makeText(MenuActivity.this, getString(R.string.login_ok), Toast.LENGTH_LONG).show();
}
};
을 내가 할 다음과 같습니다 :
Account account = new Account(mUsername, ACCOUNT_TYPE);
try{
mAccountManager.addAccountExplicitly(account, mPassword, newBundle());
}catch(Exception e){
e.printStackTrace();
return;
}
final Intent intent = new Intent();
intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername);
intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, ACCOUNT_TYPE);
intent.putExtra(AccountManager.KEY_PASSWORD, mPassword);
intent.putExtra(AccountManager.KEY_AUTHTOKEN, mAuthToken);
intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, true);
LoginActivity.this.setAccountAuthenticatorResult(intent.getExtras());
setResult(RESULT_OK, intent);
LoginActivity.this.finish();
내가 말했듯이, 내 콜백은 호출되지 않습니다. 왜 그런가요?
[편집]
난 그냥 응용 프로그램을 다시 실행하면 내 응용 프로그램을 다시 설치해야 닫기 전에 (Eclipse-> 실행) 콜백이 권리라고 눈치.
[/ 편집] 내 AbstractAccountAuthenticator에서
를? –
응답은'AbstractAccountAuthenticator' 클래스의'public 번들 addAccount (AccountAuthenticatorResponse response, String accountType, String authTokenType, String [] requiredFeatures, 번들 옵션)'입니다. – epool