Skip to content

Commit af43fb0

Browse files
committed
remote service: Android 14 crash fix
1 parent 93376cb commit af43fb0

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/misc/RemoteControlService.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,10 @@ public void onCreate() {
3636
// NOTE: it's impossible to hide notification on Android 9 and above
3737
// https://stackoverflow.com/questions/10962418/how-to-startforeground-without-showing-notification
3838
try {
39-
//if (AppInfoHelpers.getRealSdkVersion(this) >= 34) { // Fix ForegroundServiceStartNotAllowedException
40-
// // Tie service to active media session
41-
// MediaSessionCompat mediaSession = new MediaSessionCompat(this, TAG);
42-
// mediaSession.setActive(true);
43-
//}
44-
45-
if (VERSION.SDK_INT >= 34) {
46-
// Fix ForegroundServiceStartNotAllowedException on Android 14?
47-
startForeground(NOTIFICATION_ID, createNotification(), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
48-
} else {
49-
startForeground(NOTIFICATION_ID, createNotification());
50-
}
51-
} catch (NullPointerException e) {
39+
startForeground(NOTIFICATION_ID, createNotification());
40+
} catch (Exception e) {
5241
// NullPointerException: Attempt to read from field 'int com.android.server.am.UidRecord.curProcState' on a null object reference
42+
// ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false (Android 14)
5343
e.printStackTrace();
5444
}
5545
}

0 commit comments

Comments
 (0)