You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -372,156 +372,87 @@ As a final step, we're going to allow the users of our app to log in using email
372
372
373
373

374
374
375
-
3. Now create a new layout called dialog_signin.xml
375
+
3. Extend FirebaseLoginBaseActivity
376
376
377
-

377
+
Although extending `ListActivity` was useful earlier, when it saved some lines of code, it's now more important that we extend `FirebaseLoginBaseActivity`.
378
378
379
-
4. In this dialog_signin.xml, we'll model the body of the sign-in dialog
Inthiscode, we always try to register the user. If the user already registered that will result in `onError`, otherwise it will result on onSuccess.
401
+

465
402
466
-
Either way, we next call `authWithPassword` to authenticate the (pre-existingorjust-created) user.
467
-
468
-

469
-
470
-
6. With the above we have the registration/login flow working. But we still need to listen to when Firebase Authentication tells us the user has been authenticated, so that we can store the username and use that in the chat message instead of the hard-coded value we have now.
471
-
472
-
Add a field to the class to hold the user name:
403
+
Finally we need to add a few event handlers onto `MainActivity` so we can react to login events.
473
404
474
405
```java
475
-
String mUsername;
476
-
```
406
+
@Override
407
+
protectedFirebase getFirebaseRef() {
408
+
return mFirebaseRef;
409
+
}
477
410
478
-
Add the end of the `onCreate` method, add a callback method that listens for authentication state changes in Firebase:
Firebase calls our listener whenever the authentication state changes, so whenever the user logs in or out. When the user logs in, we store their email address in our field and hide the login button.
Firebase Authentication supports multiple authentication providers and each of them exposes a different set of data. For example, if we'd allow our users to authenticate with their existing Twitter account, we could identify them by their twitter handle.
422
+

501
423
502
-
7. Finally, replace the hard-coded username with the field we just populated:
0 commit comments