From 1babd0a5e4e240dd20aaf94f78d5da203b55e2df Mon Sep 17 00:00:00 2001 From: larshuth Date: Tue, 7 May 2024 23:04:01 +0200 Subject: [PATCH 1/2] checked serviceBindManager for null value if not initialized --- .../FlutterNearbyConnectionsPlugin.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/com/nankai/flutter_nearby_connections/FlutterNearbyConnectionsPlugin.kt b/android/src/main/kotlin/com/nankai/flutter_nearby_connections/FlutterNearbyConnectionsPlugin.kt index 54f268c..d99c53e 100644 --- a/android/src/main/kotlin/com/nankai/flutter_nearby_connections/FlutterNearbyConnectionsPlugin.kt +++ b/android/src/main/kotlin/com/nankai/flutter_nearby_connections/FlutterNearbyConnectionsPlugin.kt @@ -136,9 +136,11 @@ class FlutterNearbyConnectionsPlugin : FlutterPlugin, MethodCallHandler, Activit override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { channel.setMethodCallHandler(null) - serviceBindManager.mService?.stopAdvertising() - serviceBindManager.mService?.stopDiscovery() - serviceBindManager.unbindService() + if (serviceBindManager != null) { + serviceBindManager.mService?.stopAdvertising() + serviceBindManager.mService?.stopDiscovery() + serviceBindManager.unbindService() + } locationHelper = null exitProcess(0) } From 23e4b34f95f8bafbf3f7cde7a5b22df9e095b4ca Mon Sep 17 00:00:00 2001 From: larshuth Date: Sun, 19 May 2024 13:32:24 +0200 Subject: [PATCH 2/2] to fix app kill and the crash with missing permissions -> added special use to AndroidManifest.xml --- android/src/main/AndroidManifest.xml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index b47af3a..57aaf92 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -18,13 +18,28 @@ + + + + + + - + android:name=".NearbyService" + android:enabled="true" + android:exported="false" + android:foregroundServiceType="specialUse"> + + + -