android4.4以前的就有这个功能:
Android自定义账户类型和同步适配器模式 Custom Account Type & SyncAdapter
http://blog.csdn.net/w804518214/article/details/52820878
检查账号密码
android\frameworks\base\core\java\android\accounts\AccountManager.java
/**
* Confirms that the user knows the password for an account to make extra
* sure they are the owner of the account. The user-entered password can
* be supplied directly, otherwise the authenticator for this account type
* prompts the user with the appropriate interface. This method is
* intended for applications which want extra assurance; for example, the
* phone lock screen uses this to let the user unlock the phone with an
* account password if they forget the lock pattern.
*
* <p>If the user-entered password matches a saved password for this
* account, the request is considered valid; otherwise the authenticator
* verifies the password (usually by contacting the server).
*
* <p>This method may be called from any thread, but the returned
* {@link AccountManagerFuture} must not be used on the main thread.
*
* <p><b>NOTE:</b> If targeting your app to work on API level 22 and before,
* MANAGE_ACCOUNTS permission is needed for those platforms. See docs
* for this function in API level 22.
*
* @param account The account to confirm password knowledge for
* @param options Authenticator-specific options for the request;
* if the {@link #KEY_PASSWORD} string field is present, the
* authenticator may use it directly rather than prompting the user;
* may be null or empty
* @param activity The {@link Activity} context to use for launching a new
* authenticator-defined sub-Activity to prompt the user to enter a
* password; used only to call startActivity(); if null, the prompt
* will not be launched directly, but the necessary {@link Intent}
* will be returned to the caller instead
* @param callback Callback to invoke when the request completes,
* null for no callback
* @param handler {@link Handler} identifying the callback thread,
* null for the main thread
* @return An {@link AccountManagerFuture} which resolves to a Bundle
* with these fields if activity or password was supplied and
* the account was successfully verified:
* <ul>
* <li> {@link #KEY_ACCOUNT_NAME} - the name of the account verified
* <li> {@link #KEY_ACCOUNT_TYPE} - the type of the account
* <li> {@link #KEY_BOOLEAN_RESULT} - true to indicate success
* </ul>
*
* If no activity or password was specified, the returned Bundle contains
* {@link #KEY_INTENT} with the {@link Intent} needed to launch the
* password prompt.
*
* <p>Also the returning Bundle may contain {@link
* #KEY_LAST_AUTHENTICATED_TIME} indicating the last time the
* credential was validated/created.
*
* If an error occurred,{@link AccountManagerFuture#getResult()} throws:
* <ul>
* <li> {@link AuthenticatorException} if the authenticator failed to respond
* <li> {@link OperationCanceledException} if the operation was canceled for
* any reason, including the user canceling the password prompt
* <li> {@link IOException} if the authenticator experienced an I/O problem
* verifying the password, usually because of network trouble
* </ul>
*/
public AccountManagerFuture<Bundle> confirmCredentials(final Account account,
final Bundle options,
final Activity activity,
final AccountManagerCallback<Bundle> callback,
final Handler handler) {
return confirmCredentialsAsUser(account, options, activity, callback, handler,
Process.myUserHandle());
}