Activity Flow
Finally we update the navigation between activities. The following figure shows the transitions.

| In | State /action | New Activity |
|---|---|---|
| MainActivity | User is not signed (check in onStart()) | SignInActivity |
| MainActivity | User selects corresponding entry in options menu | ManageAccountActivity |
| MainActivity | - User selects corresponding entry in options menu User clicks on entry in postlist | PostActivity |
| SignInActivity | User clicks on CreateAccount | CreateAccount |
Find some remarks on implementation below:
Activity Back Stack
If activity A starts a new activity B, then B is pushed to the activity stack. If the user presses the Back button, that new activity is finished and popped off the stack. We will not dive into the details of managing the activity stack. You can find detailed information here.
MainActivity
Link to SignInActivity
After starting the app, we check the authentication state. If user is not authenticated, jump to SignInActivity immediately. Add this code to the method onStart()
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser == null) {
Log.d(TAG, "User not authenticated! ");
Intent intent = new Intent(getApplication(),
SignInActivity.class);
startActivity(intent);
}
Link to ManageAccountActivity
After a click in the respective entry of the options menu, navigate to ManageAccountActivityin the onOptionsItemSelected-method.
Link to PostActivity
After a click in the respective entry of the options menu, navigate to PostActivityin the onOptionsItemSelected-method.
SignInActivity
The SignInActivityneeds the following changes:
- After successful logon the activity shall finish.
- A click on Create New Account shall start the
CreateAccountActivity
CreateAccountActivity
The CreateAccountActivityneeds the following changes: after successful account creation the activity shall finish.
ManageAccountActivity
The ManageAccountActivityneeds the following changes:
- After SignOut the activity shall finish.
- After DeleteAccount the activity shall finish.
- In the first three textlines display
- account verification state
- Firebase user-id
PostActivity
The PostActivityneeds the following changes: after _posting _the activity shall finish