Open JosephSanjaya opened 2 years ago
Any solution?, my company need to release the app in 1 week, im using this to download report. can you look forward to it?
too
This is not fixed yet so if anyone else encountered this issue, implement DefaultFetchNotificationManager
, override getActionPendingIntent
and just add everything already added plus the mutability flag like this:
override fun getActionPendingIntent(
downloadNotification: DownloadNotification,
actionType: DownloadNotification.ActionType
): PendingIntent {
val intent = Intent(notificationManagerAction)
intent.putExtra(EXTRA_NAMESPACE, downloadNotification.namespace)
intent.putExtra(EXTRA_DOWNLOAD_ID, downloadNotification.notificationId)
intent.putExtra(EXTRA_NOTIFICATION_ID, downloadNotification.notificationId)
intent.putExtra(EXTRA_GROUP_ACTION, false)
intent.putExtra(EXTRA_NOTIFICATION_GROUP_ID, downloadNotification.groupId)
val action = when (actionType) {
DownloadNotification.ActionType.CANCEL -> ACTION_TYPE_CANCEL
DownloadNotification.ActionType.DELETE -> ACTION_TYPE_DELETE
DownloadNotification.ActionType.RESUME -> ACTION_TYPE_RESUME
DownloadNotification.ActionType.PAUSE -> ACTION_TYPE_PAUSE
DownloadNotification.ActionType.RETRY -> ACTION_TYPE_RETRY
else -> ACTION_TYPE_INVALID
}
intent.putExtra(EXTRA_ACTION_TYPE, action)
//add the following lines to fix the issue
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
PendingIntent.getBroadcast(context, downloadNotification.notificationId + action, intent, PendingIntent.FLAG_IMMUTABLE)
else
PendingIntent.getBroadcast(context, downloadNotification.notificationId + action, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
Tested and working without any issue on Android 12+
Library crash when building pending intent for notification
Expected Behavior
Application not crashing when using DefaultFetchNotificationManager
Current Behavior
Crash catch stack:
Possible Solution
Add FLAG_IMMUTABLE or FLAG_MUTABLE flag on PendingIntent