diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java b/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java index e43b208ca..671edf710 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java @@ -17,14 +17,13 @@ import android.os.AsyncTask; import android.os.IBinder; import android.text.TextUtils; import android.util.Log; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; import androidx.core.app.ServiceCompat; import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; - +import cc.mvdan.accesspoint.WifiApControl; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.NotificationHelper; import org.fdroid.fdroid.Preferences; @@ -48,8 +47,6 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; -import cc.mvdan.accesspoint.WifiApControl; - /** * Central service which manages all of the different moving parts of swap which are required * to enable p2p swapping of apps. @@ -429,7 +426,9 @@ public class SwapService extends Service { localBroadcastManager.unregisterReceiver(bonjourPeerFound); localBroadcastManager.unregisterReceiver(bonjourPeerRemoved); - unregisterReceiver(bluetoothScanModeChanged); + if (bluetoothAdapter != null) { + unregisterReceiver(bluetoothScanModeChanged); + } BluetoothManager.stop(this);