Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Você pode permitir que os usuários saiam do app e desconectem as
contas deles completamente.
Desconectar usuários
Para adicionar um botão de logout ao app, primeiro crie um botão para
servir como botão de logout. Em seguida, anexe um
onClickListener
ao botão e configure o método onClick para chamar
signOut.
Esse código remove a conta que estiver conectada ao app. Para fazer login de novo, o
usuário precisa escolher a conta novamente.
Desconectar contas
É altamente recomendável fornecer aos usuários que fizeram login com o Google a
capacidade de desconectar a Conta do Google do seu app. Se o usuário excluir
a conta dele, você precisará remover as informações que o app recebeu das
APIs do Google.
O código a seguir mostra um exemplo simples de como chamar o
método
revokeAccess:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-31 UTC."],[[["\u003cp\u003eGoogle Sign-In for Android is outdated and developers should migrate to Credential Manager for enhanced security and user experience, except for Wear OS 3, 4, and 5.0 which need to continue using Google Sign-In for Android.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can implement sign-out functionality in their apps, requiring users to re-select their account for subsequent sign-ins.\u003c/p\u003e\n"],["\u003cp\u003eIt is crucial for developers to allow users to disconnect their Google accounts from the app, and delete user data if the user deletes their Google account.\u003c/p\u003e\n"]]],[],null,["# Signing Out Users and Disconnecting Accounts\n\n| **Warning:** Google Sign-In for Android is outdated and no longer supported. To ensure the continued security and usability of your app, [migrate\n| to Credential Manager](https://developer.android.com/training/sign-in/credential-manager/) today. Credential Manager supports passkey, password, and federated identity authentication (such as Sign-in with Google), stronger security, and a more consistent user experience. For Wear developers: Credential Manager will be supported in Wear OS 5.1 and later on selected watches. Developers actively supporting Wear OS 3, 4 and 5.0 devices with Sign in with Google should continue using Google Sign-in for Android for your Wear applications. Sign in with Google support will be available on Credential Manager APIs for these versions of WearOS at a later date.\n\nYou can enable your users to sign out of your app, and to disconnect their\naccounts from your app entirely.\n\nSign out users\n--------------\n\nTo add a sign out button to your app, first create a button in your app to act\nas your sign out button. Then, attach an\n[`onClickListener`](https://developer.android.com/reference/android/view/View.OnClickListener.html)\nto the button and configure the `onClick` method to call\n[`signOut`](/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInClient#signOut()). \n\n @Override\n public void onClick(View v) {\n switch (v.getId()) {\n // ...\n case R.id.button_sign_out:\n signOut();\n break;\n // ...\n }\n }\n\n```transact-sql\nprivate void signOut() {\n mGoogleSignInClient.signOut()\n .addOnCompleteListener(this, new OnCompleteListener\u003cVoid\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cVoid\u003e task) {\n // ...\n }\n });\n}\n```\n\nThis code clears which account is connected to the app. To sign in again, the\nuser must choose their account again.\n\nDisconnect accounts\n-------------------\n\nIt is highly recommended that you provide users that signed in with Google the\nability to disconnect their Google account from your app. If the user deletes\ntheir account, you must delete the information that your app obtained from the\nGoogle APIs.\n\nThe following code shows a simple example of calling the\n[`revokeAccess`](/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInClient#revokeAccess())\nmethod: \n\n```transact-sql\nprivate void revokeAccess() {\n mGoogleSignInClient.revokeAccess()\n .addOnCompleteListener(this, new OnCompleteListener\u003cVoid\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cVoid\u003e task) {\n // ...\n }\n });\n}\n```\n\nIn the completion listener, you can respond to the event and trigger any\nappropriate logic in your app or your back-end code."]]