Reputation: 2865
I'm trying to create a PendingIntent
using PendindIntent.getBroadcast()
but it always returns null despite the docs cleary stating:
@return Returns an existing or new PendingIntent matching the given parameters. May return null only if {@link #FLAG_NO_CREATE} has been supplied.
I'm not using FLAG_NO_CREATE so it should never return null.
private fun createAlertPendingIntent(
context: Context,
notification: Notification,
intentId: Int) : PendingIntent {
val notificationIntent = Intent(context, NotificationPublisher::class.java)
notificationIntent.putExtra(KEY_NOTIFICATION, notification)
val pi = PendingIntent.getBroadcast(
context,
intentId,
notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT)
return pi // IS NULL
}
Upvotes: 0
Views: 1047
Reputation: 2865
Apparently PendingIntent.getBroadcast()
can return null without any warnings or errors if something isn't right with intent you pass into it.
In my case, the notificationIntent had a Notification
in it where the drawable used in .setLargeIcon(drawable)
wasn't sized correctly or avalaible for all of the screen densities. Adding it to the mdpi, hdpi, xhdpi, etc folders solved it for me.
Upvotes: 2