【Android源码 栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。
网学会员整理了Android源码 -[SampleSyncAdapter工程][android源码][authenticator-Authenticator java] - 开发文档的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
/ Copyright C 2010 The Android Open Source Project Licensed under the Apache License Version 2.0 the License you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. See the License for the specific language governing permissions and limitations under the License. / package com.example.android.samplesync.authenticator import android.accounts.AbstractAccountAuthenticator import android.accounts.Account import android.accounts.AccountAuthenticatorResponse import android.accounts.AccountManager import android.content.Context import android.content.Intent import android.os.Bundle import com.example.android.samplesync.Constants import com.example.android.samplesync.R import com.example.android.samplesync.client.NetworkUtilities / This class is an implementation of AbstractAccountAuthenticator for authenticating accounts in the com.example.android.samplesync domain. / class Authenticator extends AbstractAccountAuthenticator // Authentication Service context private final Context mContext public AuthenticatorContext context supercontext mContext context Override public Bundle addAccountAccountAuthenticatorResponse response String accountType String authTokenType String requiredFeatures Bundle options final Intent intent new IntentmContext AuthenticatorActivity.class intent.putExtraAuthenticatorActivity.PARAM_AUTHTOKEN_TYPE authTokenType intent.putExtraAccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE response final Bundle bundle new Bundle bundle.putParcelableAccountManager.KEY_INTENT intent return bundle Override public Bundle confirmCredentialsAccountAuthenticatorResponse response Account account Bundle options if options null options.containsKeyAccountManager.KEY_PASSWORD final String password options.getStringAccountManager.KEY_PASSWORD final boolean verified onlineConfirmPasswordaccount.name password final Bundle result new Bundle result.putBooleanAccountManager.KEY_BOOLEAN_RESULT verified return result // Launch AuthenticatorActivity to confirm credentials final Intent intent new IntentmContext AuthenticatorActivity.class intent.putExtraAuthenticatorActivity.PARAM_USERNAME account.name intent.putExtraAuthenticatorActivity.PARAM_CONFIRM_CREDENTIALS true intent.putExtraAccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE response final Bundle bundle new Bundle bundle.putParcelableAccountManager.KEY_INTENT intent return bundle Override public Bundle editPropertiesAccountAuthenticatorResponse response String accountType throw new UnsupportedOperationException Override public Bundle getAuthTokenAccountAuthenticatorResponse response Account account String authTokenType Bundle loginOptions if authTokenType.equalsConstants.AUTHTOKEN_TYPE final Bundle result ne