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
Copy file name to clipboardExpand all lines: codelabs/chat/README.md
+23-39Lines changed: 23 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,12 @@ What you'll learn:
10
10
11
11
The steps:
12
12
13
-
1. Register with Firebase
14
-
2. Create a project in Android Studio
15
-
3. Connect the Android app to Firebase
16
-
4.Allow the user to send a message
17
-
5. Show the messages
18
-
6. Enable login
13
+
1.[Register with Firebase](#register-with-firebase)
14
+
2.[Create a project in Android Studio](#create-a-project-in-android-studio)
15
+
3.[Connect the Android app to Firebase](#connect-the-android-app-to-firebase)
16
+
4.[Send a message](#send-a-message)
17
+
5.[Show the messages](#show-the-messages)
18
+
6.[Enable login](#enable-login)
19
19
20
20
What you'll need
21
21
*[Android Studio](https://developer.android.com/sdk/installing/studio.html) version 1.3 or up
@@ -80,36 +80,20 @@ In this step we'll create a project in Android Studio.
80
80
81
81
## Connect the Android app to Firebase
82
82
83
-
Before we can start writing code that interacts with our Firebase database, we'll need to make Android Studio aware that we'll be using Firebase. We need to do this in two places: in our app's `gradle.build` script and in our`AndroidManifest.xml`.
83
+
Before we can start writing code that interacts with our Firebase database, we'll need to make Android Studio aware that we'll be using Firebase. We need to do this in a few places: in the `gradle.build` script for out app and in its`AndroidManifest.xml`.
84
84
85
-
1.Right-click on the app and click Open Module Settings
7. open Gradle Scripts > build.gradle (Module: app)
94
+
This tells Gradle to include the Firebase SDK and the FirebaseUI library.
110
95
111
-
This file contains the steps that Android Studio uses to build our app. We'll add a reference to Firebase to it, so we can start using it.
112
-
8. Add the following inside the `android` object:
96
+
3. Add the following inside the `android` object:
113
97
114
98
packagingOptions {
115
99
exclude 'META-INF/LICENSE'
@@ -121,30 +105,30 @@ Before we can start writing code that interacts with our Firebase database, we'l
121
105
122
106
[screenshot:gradle.build]
123
107
124
-
9. At this stage you'll need to synchronize the project with the gradle files again, so Tools > Android > Sync Project with Gradle Files. Android Studio will parse the gradle files and pick up our changes.
108
+
4. At this stage you'll need to synchronize the project with the gradle files again, so Tools > Android > Sync Project with Gradle Files. Android Studio will parse the gradle files and pick up our changes.
125
109
126
110
[screenshot:Sync now]
127
111
128
-
10. Since Firebase is a hosted service, our app will need to be able to access the internet.
129
-
11. Open app > manifests > AndroidManifest.xml
130
-
12. Add this line inside the `manifest` element:
112
+
5. Since Firebase is a hosted service, our app will need to be able to access the internet.
13. Now we can get to the Java code. The first step there is to set up initial connection between our code and its Firebase backend.
120
+
8. Now we can get to the Java code. The first step there is to set up initial connection between our code and its Firebase backend.
137
121
open MainActivity.java and add this code to the end of the onCreate method:
138
122
139
123
Firebase.setAndroidContext(this);
140
124
141
125
This code allows the Firebase client to keep its context.
142
-
14. Import Firebase at the top of your MainActivity by adding the following line:
126
+
9. Import Firebase at the top of your MainActivity by adding the following line:
143
127
144
128
import com.firebase.client.Firebase;
145
129
146
-
15. If Android Studio is having trouble finding the Firebase class, be sure that you've added dependencies and have synchronized the build file with the project.
147
-
16. We also want to create a connection to our database. We'll keep this connection in a member field:
130
+
10. If Android Studio is having trouble finding the Firebase class, be sure that you've added dependencies and have synchronized the build file with the project.
131
+
11. We also want to create a connection to our database. We'll keep this connection in a member field:
148
132
149
133
private Firebase mFirebaseRef;
150
134
@@ -158,7 +142,7 @@ This code allows the Firebase client to keep its context.
158
142
159
143
That's all the setup that is required. Next up we'll allow the user to enter a message in our app and send the message to Firebase.
160
144
161
-
## Allow the user to send a message
145
+
## Send a message
162
146
163
147
Now we can start sending data to Firebase! In this step we'll allow the user to enter a message in a text box. When they then click the Send button, we will send the message to Firebase.
0 commit comments