mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-02 15:15:09 +00:00
Catch BackgroundServiceStartNotAllowedException
This commit is contained in:
@@ -41,7 +41,6 @@ public class RunCommandWidget extends AppWidgetProvider {
|
|||||||
|
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
plugin.runCommand(targetCommand);
|
plugin.runCommand(targetCommand);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.e("RunCommandWidget", "Error running command", ex);
|
Log.e("RunCommandWidget", "Error running command", ex);
|
||||||
@@ -51,10 +50,14 @@ public class RunCommandWidget extends AppWidgetProvider {
|
|||||||
setCurrentDevice(context);
|
setCurrentDevice(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// FIXME: Remove the need for a background service, we are not allowed to start them in API 31+
|
||||||
final Intent newIntent = new Intent(context, RunCommandWidgetDataProviderService.class);
|
final Intent newIntent = new Intent(context, RunCommandWidgetDataProviderService.class);
|
||||||
context.startService(newIntent);
|
context.startService(newIntent);
|
||||||
updateWidget(context);
|
updateWidget(context);
|
||||||
|
} catch(IllegalStateException exception) { // Meant to catch BackgroundServiceStartNotAllowedException on API 31+
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCurrentDevice(final Context context) {
|
private void setCurrentDevice(final Context context) {
|
||||||
|
Reference in New Issue
Block a user