今日、私のアプリケーションにはクラシックなログイン画面(ユーザー名とパスワード)があり、このクラスは共通のアクティビティを拡張しています。私の最初の活動はログインです(すでにログインしているユーザーがログインしている場合は自宅にリダイレクトされます)。Android - AccountManagerとLogin classic
マイアンドロイドマニフェスト:
<!-- Start Activity -->
<activity
android:name=".activity.LoginActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
そして今、私は、Androidのアカウントマネージャを展開しようとしているが、マニュアルを読み、実装します。この機能は大丈夫です。 Androidアカウントの設定を入力すると、アプリにログインしてアカウントを作成することができます。しかし、私の質問は両方の方法を維持する方法です。
facebookとして、ユーザーがアプリケーションを開くと、ログインして自動的にAccountManager上にアカウントが作成され、設定でアカウントに取得され、アプリケーションにも記録されます。バレーボールを使用してサーバー上でユーザーの検証とパスワードを要求したら、どのような手順を実行する必要がありますか?データをAccountManagerに返すか、アカウントを追加しますか?
ログインクラシック、サーバーの検証は「addAccountExplicitly」を使用してアカウントを追加した後:あなたがいない両方の方法を保つために
Bundle data = new Bundle();
data.putString(AccountManager.KEY_ACCOUNT_NAME, email);
data.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
data.putString(AccountManager.KEY_AUTHTOKEN, authToken);
data.putString(PARAM_USER_PASS, password);
final Intent intent = new Intent();
intent.putExtras(data);
final Account account = new Account(email, accountType);
if (getIntent().getBooleanExtra(ARG_IS_ADDING_NEW_ACCOUNT, false)) {
Log.d(TAG, " finishLogin > addAccountExplicitly");
// Creating the account on the device and setting the auth token we got
// (Not setting the auth token will cause another call to the server to authenticate the user)
mAccountManager.addAccountExplicitly(account, password, null);
mAccountManager.setAuthToken(account, mAuthTokenType, authToken);
} else {
Log.d(TAG, " finishLogin > setPassword");
mAccountManager.setPassword(account, password);
}
setAccountAuthenticatorResult(intent.getExtras());
setResult(RESULT_OK, intent);
finish();