From 99b3dc3226f98e3b2adf322f62efdbc105311a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Tue, 28 Nov 2023 18:12:12 +0000 Subject: [PATCH] Fix crash when pairing current device as companion --- .../gadgetbridge/activities/DebugActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java index 0fbbd2209..2be4d031d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java @@ -63,6 +63,7 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AlertDialog; import androidx.core.app.ActivityCompat; @@ -778,7 +779,7 @@ public class DebugActivity extends AbstractGBActivity { final GBDevice device = devices.get(0); - final CompanionDeviceManager manager = (CompanionDeviceManager) GBApplication.getContext().getSystemService(Context.COMPANION_DEVICE_SERVICE); + final CompanionDeviceManager manager = (CompanionDeviceManager) getSystemService(Context.COMPANION_DEVICE_SERVICE); if (manager.getAssociations().contains(device.getAddress())) { GB.toast(device.getAliasOrName() + " already paired as companion", Toast.LENGTH_LONG, GB.INFO); @@ -801,7 +802,7 @@ public class DebugActivity extends AbstractGBActivity { } @Override - public void onDeviceFound(final IntentSender chooserLauncher) { + public void onDeviceFound(@NonNull final IntentSender chooserLauncher) { GB.toast("Found device", Toast.LENGTH_SHORT, GB.INFO); try {