2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 21:55:10 +00:00

Fixed NPE when contentIntent is triggered

This commit is contained in:
Erik Duisters
2019-03-03 14:52:23 +00:00
parent 024a084b9a
commit 9d5a6fa0fd

View File

@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -308,10 +309,14 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
iOpenActivity.putExtra("deviceId", notificationDevice);
iOpenActivity.putExtra("player", notificationPlayer.getPlayer());
/*
TODO: Remove when Min SDK >= 16
The only way the intent extra's are delivered on API 14 and 15 is by either using a different requestCode every time
or using PendingIntent.FLAG_CANCEL_CURRENT instead of PendingIntent.FLAG_UPDATE_CURRENT
*/
PendingIntent piOpenActivity = TaskStackBuilder.create(context)
.addParentStack(MprisActivity.class)
.addNextIntent(iOpenActivity)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
.addNextIntentWithParentStack(iOpenActivity)
.getPendingIntent(Build.VERSION.SDK_INT > 15 ? 0 : (int)System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NotificationHelper.Channels.MEDIA_CONTROL);