@@ -171,8 +171,12 @@ private boolean isGooglePlayServicesAvailable() {
171
171
protected void onResume () {
172
172
super .onResume ();
173
173
174
- // Display the connection status
174
+ displayLocation ();
175
175
176
+ MapDemoActivityPermissionsDispatcher .startLocationUpdatesWithPermissionCheck (this );
177
+ }
178
+
179
+ private void displayLocation () {
176
180
if (mCurrentLocation != null ) {
177
181
Toast .makeText (this , "GPS location was found!" , Toast .LENGTH_SHORT ).show ();
178
182
LatLng latLng = new LatLng (mCurrentLocation .getLatitude (), mCurrentLocation .getLongitude ());
@@ -181,7 +185,6 @@ protected void onResume() {
181
185
} else {
182
186
Toast .makeText (this , "Current location was null, enable GPS on emulator!" , Toast .LENGTH_SHORT ).show ();
183
187
}
184
- MapDemoActivityPermissionsDispatcher .startLocationUpdatesWithPermissionCheck (this );
185
188
}
186
189
187
190
@ NeedsPermission ({Manifest .permission .ACCESS_FINE_LOCATION , Manifest .permission .ACCESS_COARSE_LOCATION })
@@ -213,13 +216,12 @@ public void onLocationChanged(Location location) {
213
216
return ;
214
217
}
215
218
216
- // Report to the UI that the location was updated
217
-
218
219
mCurrentLocation = location ;
219
220
String msg = "Updated Location: " +
220
221
Double .toString (location .getLatitude ()) + "," +
221
222
Double .toString (location .getLongitude ());
222
223
Toast .makeText (this , msg , Toast .LENGTH_SHORT ).show ();
224
+ displayLocation ();
223
225
}
224
226
225
227
public void onSaveInstanceState (Bundle savedInstanceState ) {
0 commit comments