Try not blocking main threads to start foreground service.

This commit is contained in:
Clark
2023-05-17 13:43:01 -04:00
committed by Greyson Parrelli
parent 99d3f9918f
commit 534c5c3c64
4 changed files with 16 additions and 5 deletions

View File

@@ -277,7 +277,7 @@ public class VoiceNotePlaybackService extends MediaBrowserServiceCompat {
public void onNotificationPosted(int notificationId, Notification notification, boolean ongoing) {
if (ongoing && !isForegroundService) {
try {
ForegroundServiceUtil.startWhenCapable(getApplicationContext(), new Intent(getApplicationContext(), VoiceNotePlaybackService.class));
ForegroundServiceUtil.start(getApplicationContext(), new Intent(getApplicationContext(), VoiceNotePlaybackService.class));
startForeground(notificationId, notification);
isForegroundService = true;
} catch (UnableToStartException e) {