Authenticate with Firebase Anonymously on Android

You can use Firebase Authentication to create and use temporary anonymous accounts
to authenticate with Firebase. These temporary anonymous accounts can be used to
allow users who haven't yet signed up to your app to work with data protected
by security rules. If an anonymous user decides to sign up to your app, you can
link their sign-in credentials to the anonymous
account so that they can continue to work with their protected data in
future sessions.

If sign-in succeeds you can use the getCurrentUser method to get the user's account data.

To protect your project from abuse, Firebase limits the number of new
email/password and anonymous sign-ups that your application can have from the
same IP address in a short period of time. You can request and schedule
temporary changes to this quota from the
Firebase console.

Convert an anonymous account to a permanent account

When an anonymous user signs up to your app, you might want to allow them to
continue their work with their new account—for example, you might want to
make the items the user added to their shopping cart before they signed up
available in their new account's shopping cart. To do so, complete the following
steps:

When the user signs up, complete the sign-in flow for the user's
authentication provider up to, but not including, calling one of the
FirebaseAuth.signInWith methods. For example, get the user's Google ID token,
Facebook access token, or email address and password.