WorkAccountClient
Stay organized with collections
Save and categorize content based on your preferences.
Client to manage Android for Work Accounts. This class provides methods for managing the
lifecycle of work accounts.
Android for Work Accounts are for organizations that don't use Google Accounts. For
details, see the EMM Developer's
Overview
.
Inherited Method Summary
From class com.google.android.gms.common.api.GoogleApi
getApiFallbackAttributionTag
( Context
arg0)
From class java.lang.Object
Public Methods
public Task< Account
>
addWorkAccount
( String
token)
Parameters
token
OAuth token for the account.
Returns
-
Task
indicating whether adding the account has succeeded.
public Task< Void
>
removeWorkAccount
( Account
account)
Parameters
account
the account to be removed.
Returns
-
Task
indicating whether removing the account has succeeded.
public Task< Void
>
setWorkAuthenticatorEnabled
(boolean
enabled)
Parameters
enabled
true
to enable work accounts; false
to disable work
accounts.
Returns
-
Task
indicating whether enabling or disabling work accounts request has been accepted by AccountManager
.
Please note that the actual enabling or disabling operation is performed
asynchronously.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-23 UTC."],[[["\u003cp\u003e\u003ccode\u003eWorkAccountClient\u003c/code\u003e manages Android for Work Accounts, offering methods for account lifecycle management.\u003c/p\u003e\n"],["\u003cp\u003eIt is specifically designed for organizations that do not utilize Google Accounts.\u003c/p\u003e\n"],["\u003cp\u003eThe client provides functionality to add, remove, and control the availability of work accounts within the Android Account Manager.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eWorkAccountClient\u003c/code\u003e uses tasks to indicate the success or acceptance of these account operations.\u003c/p\u003e\n"]]],["The `WorkAccountClient` manages Android for Work accounts, which are for organizations not using Google Accounts. Key actions include: adding a work account using `addWorkAccount(String token)`, which utilizes an OAuth token; removing an account using `removeWorkAccount(Account account)`; and enabling/disabling work account availability in `AccountManager` with `setWorkAuthenticatorEnabled(boolean enabled)`. Each of these methods returns a `Task` to indicate success or failure. `getApiFallbackAttributionTag(Context arg0)` is inherited from `GoogleApi`.\n"],null,["# WorkAccountClient\n\npublic class **WorkAccountClient** extends [GoogleApi](/android/reference/com/google/android/gms/common/api/GoogleApi)\\\u003c[Api.ApiOptions.NoOptions](/android/reference/com/google/android/gms/common/api/Api.ApiOptions.NoOptions)\\\u003e \nClient to manage Android for Work Accounts. This class provides methods for managing the\nlifecycle of work accounts.\n\nAndroid for Work Accounts are for organizations that don't use Google Accounts. For\ndetails, see the [EMM Developer's\nOverview](//developers.google.com/android/work/overview). \n\n### Public Method Summary\n\n|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Task\\\u003c[Account](//developer.android.com/reference/android/accounts/Account.html)\\\u003e | [addWorkAccount](/android/reference/com/google/android/gms/auth/account/WorkAccountClient#addWorkAccount(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) token) Adds a work account to [AccountManager](//developer.android.com/reference/android/accounts/AccountManager.html). |\n| Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [removeWorkAccount](/android/reference/com/google/android/gms/auth/account/WorkAccountClient#removeWorkAccount(android.accounts.Account))([Account](//developer.android.com/reference/android/accounts/Account.html) account) Removes a work account from [AccountManager](//developer.android.com/reference/android/accounts/AccountManager.html). |\n| Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [setWorkAuthenticatorEnabled](/android/reference/com/google/android/gms/auth/account/WorkAccountClient#setWorkAuthenticatorEnabled(boolean))(boolean enabled) Changes the availability of work accounts in [AccountManager](//developer.android.com/reference/android/accounts/AccountManager.html). |\n\n### Inherited Method Summary\n\nFrom class com.google.android.gms.common.api.GoogleApi \n\n|-------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|\n| [String](//developer.android.com/reference/java/lang/String.html) | getApiFallbackAttributionTag([Context](//developer.android.com/reference/android/content/Context.html) arg0) |\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public Task\\\u003c[Account](//developer.android.com/reference/android/accounts/Account.html)\\\u003e\n**addWorkAccount** ([String](//developer.android.com/reference/java/lang/String.html) token)\n\nAdds a work account to [AccountManager](//developer.android.com/reference/android/accounts/AccountManager.html). \n\n##### Parameters\n\n| token | OAuth token for the account. |\n|-------|------------------------------|\n\n##### Returns\n\n- [Task](/android/reference/com/google/android/gms/tasks/Task) indicating whether adding the account has succeeded. \n\n#### public Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **removeWorkAccount** ([Account](//developer.android.com/reference/android/accounts/Account.html) account)\n\nRemoves a work account from [AccountManager](//developer.android.com/reference/android/accounts/AccountManager.html). \n\n##### Parameters\n\n| account | the account to be removed. |\n|---------|----------------------------|\n\n##### Returns\n\n- [Task](/android/reference/com/google/android/gms/tasks/Task) indicating whether removing the account has succeeded. \n\n#### public Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **setWorkAuthenticatorEnabled** (boolean enabled)\n\nChanges the availability of work accounts in [AccountManager](//developer.android.com/reference/android/accounts/AccountManager.html). \n\n##### Parameters\n\n| enabled | `true` to enable work accounts; `false` to disable work accounts. |\n|---------|-------------------------------------------------------------------|\n\n##### Returns\n\n- [Task](/android/reference/com/google/android/gms/tasks/Task) indicating whether enabling or disabling work accounts request has been accepted by [AccountManager](//developer.android.com/reference/android/accounts/AccountManager.html). Please note that the actual enabling or disabling operation is performed asynchronously."]]