From 735e15cb60b01e3cd0f44b18ad653fbfad53912d Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Tue, 8 Jun 2021 14:58:18 +0200 Subject: [PATCH] fix(android): fix android crash on Android API 27, #579 --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .../src/main/java/com/lyokone/location/FlutterLocation.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b86fe87b..a6dd6427 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,7 +8,7 @@ assignees: '' --- **Describe the bug** -A clear and concise description of what the bug is. +A clear and concise description of what the bug is. Have you tried running `flutter clean` first ? **Expected behavior** A clear and concise description of what you expected to happen. diff --git a/packages/location/android/src/main/java/com/lyokone/location/FlutterLocation.java b/packages/location/android/src/main/java/com/lyokone/location/FlutterLocation.java index bd0869e7..1e559056 100644 --- a/packages/location/android/src/main/java/com/lyokone/location/FlutterLocation.java +++ b/packages/location/android/src/main/java/com/lyokone/location/FlutterLocation.java @@ -12,6 +12,7 @@ import android.location.LocationManager; import android.location.OnNmeaMessageListener; import android.os.Build; +import android.os.Bundle; import android.os.Looper; import android.util.Log; import android.util.SparseArray; @@ -236,7 +237,10 @@ public void onLocationResult(LocationResult locationResult) { } loc.put("provider", location.getProvider()); - loc.put("satelliteNumber", location.getExtras().get("satellites")); + final Bundle extras = location.getExtras(); + if (extras != null) { + loc.put("satelliteNumber", location.getExtras().get("satellites")); + } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { loc.put("elapsedRealtimeNanos", (double) location.getElapsedRealtimeNanos());