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
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,9 +105,11 @@ Before we can start writing code that interacts with our Firebase database, we'l
105
105
106
106

107
107
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. You can also click the dedicated button in the toolbar
108
+
4. At this stage you'll need to synchronize the project with the gradle files again. Either click the Sync Now link in the notification bar or the corresponding button in the toolbar: Sync Project with Gradle Files.
109
109
110
-

110
+

111
+
112
+
Android Studio will parse the gradle files and pick up our changes.
111
113
112
114
5. Since Firebase is a hosted service, our app will need to be able to access the internet.
113
115
6. Open app > manifests > AndroidManifest.xml
@@ -144,9 +146,9 @@ That's all the setup that is required. Next up we'll allow the user to enter a m
144
146
145
147
## Send a message
146
148
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.
149
+
Next we'll send 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.
148
150
149
-
[screenshot:forge+send message]
151
+

150
152
151
153
1. We'll first add the necessary views to activity_main.xml:
152
154
@@ -170,16 +172,16 @@ Now we can start sending data to Firebase! In this step we'll allow the user to
170
172
android:text="Send" />
171
173
</LinearLayout>
172
174
173
-
This layout gives us an `EditText`, where the user can enter their chat message, and a `Button` that they can click to send the message.
175
+
This layout puts a horizontal bar at the bottom that contains an `EditText`, where the user can enter their chat message, and a `Button` that they can click to send the message.
174
176
175
-
[screenshot:activity_main.xml with footer]
177
+

176
178
177
179
2. In our `MainActivity.java` we'll now add variables for the `EditText` and `Button` at the end of the onCreate method:
178
180
179
181
final EditText textEdit = (EditText) this.findViewById(R.id.text_edit);
[screenshot:main activity Java with EditText and Button bound]
184
+

183
185
184
186
3. Next, we'll add a method that grabs the text from the input and send it to our Firebase database:
185
187
@@ -197,11 +199,11 @@ Now we can start sending data to Firebase! In this step we'll allow the user to
197
199
198
200
You will have to import the packages for some of these classes. Android Studio will tell you where to import them from.
199
201
200
-
4. Here we grab the message from the EditText, add it to a Map, and send it off to Firebase. We'll look at a way to replace that Map with something more type-safe in the next section, but for now this will work.
202
+
Here we grab the message from the EditText, add it to a Map, and send it off to Firebase. We'll look at a way to replace that Map with something more type-safe in the next section, but for now this will work.
201
203
202
204
We hard-coded our user name for the moment. We'll use Firebase Authentication to make this dynamic in the last section of this code lab.
203
205
204
-
[screenshot with completed onCreate]
206
+

205
207
206
208
5. If you now run the application in the emulator, you will see an input field with a Send button that sends the message to Firebase. Open the URL of your Firebase database, and you'll see it light up green as you add new messages.
207
209
6. Open the Data tab in the Firebase Dashboard of your app. You'll see it light up green as you add new messages. Admit it, this is pretty cool!
0 commit comments