사용자가 내 앱을 시작할 때 다음을 달성하려고합니다.사용자가 로그인했는지 확인하는 동안 활동 시작을 중지하는 방법은 무엇입니까?
1- 사용자가 로그인하지 않은 상태에서 로그인 화면을 표시합니다. 2- 사용자가 이미 계정을 만들었고 유효한 토큰이있는 경우 시작 화면을 표시합니다.
이 목적으로 여기 http://www.udinic.com/에있는 자습서를 기반으로 사용자 지정 인증자를 구현했습니다.
코드가 작동하지만 내 문제는 현재 활동 UI가 잠깐 나타난 후 내 AccountAuthenticator에서 제공하는 계정 추가 UI로 전환된다는 것입니다. 어떻게 해결할 수 있습니까? 내 사용자가 응용 프로그램의 시작에 로그인하기
@Override
public void onStart(){
super.onStart();
getTokenForAccountCreateIfNeeded(AccountGeneral.ACCOUNT_TYPE, AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mAccountManager = AccountManager.get(this);
}
/**
* Get an auth token for the account.
* If not exist - add it and then return its auth token.
* If one exist - return its auth token.
* If more than one exists - show a picker and return the select account's auth token.
* @param accountType
* @param authTokenType
*/
private void getTokenForAccountCreateIfNeeded(String accountType, String authTokenType) {
final AccountManagerFuture<Bundle> future = mAccountManager.getAuthTokenByFeatures(accountType, authTokenType, null, this, null, null,
new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
Bundle bnd = null;
try {
bnd = future.getResult();
final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
showMessage(((authtoken != null) ? "SUCCESS!\ntoken: " + authtoken : "FAIL"));
} catch (Exception e) {
e.printStackTrace();
showMessage(e.getMessage());
}
}
}
, null);
}
힘 :
이
는 코드입니다. 여기 http://www.udinic.com/에있는 자습서를 기반으로 사용자 지정 인증자를 구현했습니다.