次の方法で共有


AccountManager.GetAuthTokenByFeatures Method

Definition

This convenience helper combines the functionality of #getAccountsByTypeAndFeatures, #getAuthToken, and #addAccount.

[Android.Runtime.Register("getAuthTokenByFeatures", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Landroid/app/Activity;Landroid/os/Bundle;Landroid/os/Bundle;Landroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthTokenByFeatures_Ljava_lang_String_Ljava_lang_String_arrayLjava_lang_String_Landroid_app_Activity_Landroid_os_Bundle_Landroid_os_Bundle_Landroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_ACCOUNTS")]
public virtual Android.Accounts.IAccountManagerFuture? GetAuthTokenByFeatures (string? accountType, string? authTokenType, string[]? features, Android.App.Activity? activity, Android.OS.Bundle? addAccountOptions, Android.OS.Bundle? getAuthTokenOptions, Android.Accounts.IAccountManagerCallback? callback, Android.OS.Handler? handler);
[<Android.Runtime.Register("getAuthTokenByFeatures", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Landroid/app/Activity;Landroid/os/Bundle;Landroid/os/Bundle;Landroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthTokenByFeatures_Ljava_lang_String_Ljava_lang_String_arrayLjava_lang_String_Landroid_app_Activity_Landroid_os_Bundle_Landroid_os_Bundle_Landroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_ACCOUNTS")>]
abstract member GetAuthTokenByFeatures : string * string * string[] * Android.App.Activity * Android.OS.Bundle * Android.OS.Bundle * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture
override this.GetAuthTokenByFeatures : string * string * string[] * Android.App.Activity * Android.OS.Bundle * Android.OS.Bundle * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture

Parameters

accountType
String

The account type required (see #getAccountsByType), must not be null

authTokenType
String

The desired auth token type (see #getAuthToken), must not be null

features
String[]

Required features for the account (see #getAccountsByTypeAndFeatures), may be null or empty

activity
Activity

The Activity context to use for launching new sub-Activities to prompt to add an account, select an account, and/or enter a password, as necessary; used only to call startActivity(); should not be null

addAccountOptions
Bundle

Authenticator-specific options to use for adding new accounts; may be null or empty

getAuthTokenOptions
Bundle

Authenticator-specific options to use for getting auth tokens; may be null or empty

callback
IAccountManagerCallback

Callback to invoke when the request completes, null for no callback

handler
Handler

Handler identifying the callback thread, null for the main thread

Returns

An AccountManagerFuture which resolves to a Bundle with at least the following fields: <ul> <li>#KEY_ACCOUNT_NAME - the name of the account <li>#KEY_ACCOUNT_TYPE - the type of the account <li>#KEY_AUTHTOKEN - the auth token you wanted </ul>

                If an error occurred, <code data-dev-comment-type="c">AccountManagerFuture#getResult()</code> throws:
                &lt;ul&gt;
                &lt;li&gt;<code data-dev-comment-type="c">AuthenticatorException</code> if no authenticator was registered for this
                account type or the authenticator failed to respond
                &lt;li&gt;<code data-dev-comment-type="c">OperationCanceledException</code> if the operation was canceled for any reason,
                including the user canceling any operation
                &lt;li&gt;<code data-dev-comment-type="c">IOException</code> if the authenticator experienced an I/O problem updating
                settings, usually because of network trouble
                &lt;/ul&gt;
Attributes

Remarks

This convenience helper combines the functionality of #getAccountsByTypeAndFeatures, #getAuthToken, and #addAccount.

This method gets a list of the accounts matching specific type and feature set which are visible to the caller (see #getAccountsByType for details); if there is exactly one already visible account, it is used; if there are some accounts for which user grant visibility, the user is prompted to pick one; if there are none, the user is prompted to add one. Finally, an auth token is acquired for the chosen account.

This method may be called from any thread, but the returned AccountManagerFuture must not be used on the main thread.

<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.

Java documentation for android.accounts.AccountManager.getAuthTokenByFeatures(java.lang.String, java.lang.String, java.lang.String[], android.app.Activity, android.os.Bundle, android.os.Bundle, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to