mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 22:25:08 +00:00
Fix NPE
This commit is contained in:
@@ -161,6 +161,9 @@ public class BackgroundService extends Service {
|
||||
}
|
||||
|
||||
public Device getDevice(String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return devices.get(id);
|
||||
}
|
||||
|
||||
@@ -370,15 +373,17 @@ public class BackgroundService extends Service {
|
||||
}
|
||||
|
||||
if (connectedDeviceIds.size() == 1) {
|
||||
String deviceId = connectedDeviceIds.get(0);
|
||||
Device device = getDevice(deviceId);
|
||||
if (device != null) {
|
||||
// Adding two action buttons only when there is a single device connected.
|
||||
// Setting up Send File Intent.
|
||||
Intent sendFile = new Intent(this, SendFileActivity.class);
|
||||
sendFile.putExtra("deviceId", connectedDeviceIds.get(0));
|
||||
sendFile.putExtra("deviceId", deviceId);
|
||||
PendingIntent sendPendingFile = PendingIntent.getActivity(this, 1, sendFile, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||
notification.addAction(0, getString(R.string.send_files), sendPendingFile);
|
||||
|
||||
// Checking if there are registered commands and adding the button.
|
||||
Device device = getDevice(connectedDeviceIds.get(0));
|
||||
RunCommandPlugin plugin = (RunCommandPlugin) device.getPlugin("RunCommandPlugin");
|
||||
if (plugin != null && !plugin.getCommandList().isEmpty()) {
|
||||
Intent runCommand = new Intent(this, RunCommandActivity.class);
|
||||
@@ -388,6 +393,7 @@ public class BackgroundService extends Service {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return notification.build();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user