diff --git a/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardTileService.kt b/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardTileService.kt index e57be453..128f1fd6 100644 --- a/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardTileService.kt +++ b/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardTileService.kt @@ -11,6 +11,7 @@ import android.os.Build import android.service.quicksettings.TileService import androidx.annotation.RequiresApi import org.kde.kdeconnect.BackgroundService +import org.kde.kdeconnect.Device @RequiresApi(Build.VERSION_CODES.N) class ClipboardTileService : TileService() { @@ -19,10 +20,14 @@ class ClipboardTileService : TileService() { startActivityAndCollapse(Intent(this, ClipboardFloatingActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK - putExtra("connectedDeviceIds", ArrayList(BackgroundService.getInstance().devices.values - .filter { it.isReachable && it.isPaired } - .map { it.deviceId }) - ) + var ids : List = emptyList() + val service = BackgroundService.getInstance() + if (service != null) { + ids = service.devices.values + .filter { it.isReachable && it.isPaired } + .map { it.deviceId } + } + putExtra("connectedDeviceIds", ArrayList(ids)) }) } -} \ No newline at end of file +} diff --git a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandControlsProviderService.kt b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandControlsProviderService.kt index 7a421c04..35d6fa18 100644 --- a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandControlsProviderService.kt +++ b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandControlsProviderService.kt @@ -167,7 +167,12 @@ class RunCommandControlsProviderService : ControlsProviderService() { private fun getCommandByControlId(controlId: String): CommandEntryWithDevice? { val controlIdParts = controlId.split("-") - val device = BackgroundService.getInstance().getDevice(controlIdParts[0]) + + val service = BackgroundService.getInstance(); + + if (service == null) return null + + val device = service.getDevice(controlIdParts[0]) if (device == null || !device.isPaired) return null