Merge pull request #3371 from ByteHamster/notification-action-foreground

Executing notification actions in foreground
This commit is contained in:
H. Lehmann 2019-09-03 19:14:52 +02:00 committed by GitHub
commit cbaf8818bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.NotificationCompat;
import android.support.v4.media.session.MediaSessionCompat;
@ -178,7 +179,11 @@ public class PlaybackServiceNotificationBuilder extends NotificationCompat.Build
private PendingIntent getPendingIntentForMediaAction(int keycodeValue, int requestCode) {
Intent intent = new Intent(context, PlaybackService.class);
intent.putExtra(MediaButtonReceiver.EXTRA_KEYCODE, keycodeValue);
return PendingIntent .getService(context, requestCode,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
if (Build.VERSION.SDK_INT >= 26) {
return PendingIntent.getForegroundService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
} else {
return PendingIntent.getService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
}
}