public class AuthUI
extends java.lang.Object
FirebaseApp
instance, an AuthUI instance can
be retrieved simply by calling AuthUI.getInstance()
.
If an alternative app instance is in use, call
AuthUI.getInstance(app
instead, passing the
appropriate app instance.
auth.getCurrentUser() != null
, where auth
is the FirebaseAuth
associated with your FirebaseApp
) then the sign-in process can be started by creating
a sign-in intent using AuthUI.SignInIntentBuilder
. A builder instance can be retrieved by
calling createSignInIntentBuilder()
.
The builder provides the following customization options for the authentication flow implemented by this library:
startActivityForResult(
AuthUI.getInstance().createSignInIntentBuilder().build(),
RC_SIGN_IN);
If Google Sign-in and Facebook Sign-in are also required, then this can be replaced with:
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(AuthUI.EMAIL_PROVIDER, AuthUI.GOOGLE_PROVIDER, AuthUI.FACEBOOK_PROVIDER)
.build(),
RC_SIGN_IN);
Finally, if a terms of service URL and a custom theme are required:
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(...)
.setTosUrl("https://superapp.example.com/terms-of-service.html")
.setTheme(R.style.SuperAppTheme)
.build(),
RC_SIGN_IN);
RESULT_OK
if a user is signed in, and RESULT_CANCELLED
if sign in
failed. No further information on failure is provided as it is not typically useful; the only
recourse for most apps if sign in fails is to ask the user to sign in again later, or proceed
with an anonymous account if supported.
{@code
Modifier and Type | Class and Description |
---|---|
class |
AuthUI.SignInIntentBuilder
Builder for the intent to start the user authentication flow.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EMAIL_PROVIDER
Provider identifier for email and password credentials, for use with
AuthUI.SignInIntentBuilder.setProviders(java.lang.String...) . |
static java.lang.String |
FACEBOOK_PROVIDER
Provider identifier for Facebook, for use with
AuthUI.SignInIntentBuilder.setProviders(java.lang.String...) . |
static java.lang.String |
GOOGLE_PROVIDER
Provider identifier for Google, for use with
AuthUI.SignInIntentBuilder.setProviders(java.lang.String...) . |
static int |
NO_LOGO
Default value for logo resource, omits the logo from the
AuthMethodPickerActivity |
static java.util.Set<java.lang.String> |
SUPPORTED_PROVIDERS
The set of authentication providers supported in Firebase Auth UI.
|
Modifier and Type | Method and Description |
---|---|
AuthUI.SignInIntentBuilder |
createSignInIntentBuilder()
Starts the process of creating a sign in intent, with the mandatory application
context parameter.
|
static int |
getDefaultTheme()
Default theme used by
AuthUI.SignInIntentBuilder.setTheme(int) if no theme
customization is required. |
static AuthUI |
getInstance()
Retrieves the
AuthUI instance associated with the default app, as returned by
FirebaseApp.getInstance() . |
static AuthUI |
getInstance(FirebaseApp app)
Retrieves the
AuthUI instance associated the the specified app. |
<any> |
signOut(android.app.Activity activity)
Signs the current user out, if one is signed in.
|
public static final java.lang.String EMAIL_PROVIDER
AuthUI.SignInIntentBuilder.setProviders(java.lang.String...)
.public static final java.lang.String GOOGLE_PROVIDER
AuthUI.SignInIntentBuilder.setProviders(java.lang.String...)
.public static final java.lang.String FACEBOOK_PROVIDER
AuthUI.SignInIntentBuilder.setProviders(java.lang.String...)
.public static final int NO_LOGO
AuthMethodPickerActivity
public static final java.util.Set<java.lang.String> SUPPORTED_PROVIDERS
public <any> signOut(@NonNull android.app.Activity activity)
activity
- The activity requesting the user be signed out.result.isSuccess()
, or that the sign-out attempt failed unexpectedly
(!result.isSuccess()
).public AuthUI.SignInIntentBuilder createSignInIntentBuilder()
public static AuthUI getInstance()
AuthUI
instance associated with the default app, as returned by
FirebaseApp.getInstance()
.java.lang.IllegalStateException
- if the default app is not initialized.public static AuthUI getInstance(FirebaseApp app)
AuthUI
instance associated the the specified app.@StyleRes public static int getDefaultTheme()
AuthUI.SignInIntentBuilder.setTheme(int)
if no theme
customization is required.