From 55f68729956287603d0ed6149e5cd7bb645de6b6 Mon Sep 17 00:00:00 2001 From: YuLong Yao Date: Tue, 31 May 2022 06:35:29 +0800 Subject: [PATCH] StreamingService: fix java.lang.IllegalArgumentException --- .../ca/pkay/rcloneexplorer/Services/StreamingService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ca/pkay/rcloneexplorer/Services/StreamingService.java b/app/src/main/java/ca/pkay/rcloneexplorer/Services/StreamingService.java index 75f761e6..e3c2c98d 100644 --- a/app/src/main/java/ca/pkay/rcloneexplorer/Services/StreamingService.java +++ b/app/src/main/java/ca/pkay/rcloneexplorer/Services/StreamingService.java @@ -66,12 +66,13 @@ protected void onHandleIntent(@Nullable Intent intent) { final Boolean allowRemoteAccess = intent.getBooleanExtra(ALLOW_REMOTE_ACCESS, false); final String authenticationUsername = intent.getStringExtra(AUTHENTICATION_USERNAME); final String authenticationPassword = intent.getStringExtra(AUTHENTICATION_PASSWORD); + final int pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; Intent foregroundIntent = new Intent(this, StreamingService.class); - PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, foregroundIntent, 0); + PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, foregroundIntent, pendingFlags); Intent cancelIntent = new Intent(this, ServeCancelAction.class); - PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(this, 0, cancelIntent, 0); + PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(this, 0, cancelIntent, pendingFlags); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.ic_streaming) @@ -84,7 +85,7 @@ protected void onHandleIntent(@Nullable Intent intent) { Uri uri = Uri.parse("http://127.0.0.1:" + port); Intent webPageIntent = new Intent(Intent.ACTION_VIEW, uri); webPageIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - PendingIntent webPagePendingIntent = PendingIntent.getActivity(this, 0, webPageIntent, 0); + PendingIntent webPagePendingIntent = PendingIntent.getActivity(this, 0, webPageIntent, pendingFlags); builder.setContentIntent(webPagePendingIntent); builder.setContentText(getString(R.string.streaming_service_notification_content, port)); }