2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-22 09:58:08 +00:00

Fix ForegroundServiceStartNotAllowedException in ACTION_SCREEN_ON

The same way we did for ACTION_BOOT_COMPLETED
This commit is contained in:
Albert Vaca Cintora 2023-09-06 07:42:00 +02:00
parent e9a862f27c
commit b01266d654

View File

@ -42,7 +42,12 @@ public class KdeConnectBroadcastReceiver extends BroadcastReceiver {
BackgroundService.ForceRefreshConnections(context);
break;
case Intent.ACTION_SCREEN_ON:
BackgroundService.ForceRefreshConnections(context);
try {
BackgroundService.ForceRefreshConnections(context);
} catch (IllegalStateException e) { // To catch ForegroundServiceStartNotAllowedException
Log.w("BroadcastReceiver", "Couldn't start the foreground service.");
e.printStackTrace();
}
break;
default:
Log.i("BroadcastReceiver", "Ignoring broadcast event: " + intent.getAction());