Skip to content

Commit 62d97db

Browse files
committed
Check null
1 parent b093552 commit 62d97db

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/src/main/java/com/example/mapdemo/MapDemoActivity.java

+6
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,13 @@ public void onLocationResult(LocationResult locationResult) {
202202
}
203203

204204
public void onLocationChanged(Location location) {
205+
// GPS may be turned off
206+
if (location == null) {
207+
return;
208+
}
209+
205210
// Report to the UI that the location was updated
211+
206212
mCurrentLocation = location;
207213
String msg = "Updated Location: " +
208214
Double.toString(location.getLatitude()) + "," +

0 commit comments

Comments
 (0)