7

I am trying to solve an issue that I am experiencing with notifications.

In my app, I am creating a notification (with an indeterminate progress and a randomly generated integer code) when someone clicks a list item to download a file. On the callback of the download, I update the notification to stop the progress, using the same id of the original notification. Clicking a notification is supposed to open the downloads folder on the phone (using a pending intent). All is well at this point.

The issue I am experiencing is when I click on multiple rows to download files, the notifications are grouped. Clicking on the grouped notification results in the app being restarted, and not the pending intent to open. Is this expected behaviour? If not, how can I ensure whenever the user clicks a grouped notification, the downloads folder is opened and the app is not restarted?

This is what I have so far.

Intent downloadFilesIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);

PendingIntent pendingIntent = PendingIntent.getActivity(MyActivity.this, MY_CODE, downloadFilesIntent, PendingIntent.FLAG_UPDATE_CURRENT);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), BuildConfig.NOTIFICATION_DOWNLOAD_FILE_CHANNEL)
          .setSmallIcon(R.mipmap.ic_launcher)
          .setWhen(System.currentTimeMillis())
          .setAutoCancel(true)
          .setContentTitle("File downloaded")
          .setContentIntent(pendingIntent)
          .setProgress(0, 0, false)
          .setContentText("myFileName.txt");
notificationManager.notify(downloadId, builder.build());

Any ideas what I am doing wrong?

JPM
  • 1,482
  • 5
  • 18
  • 25
  • 1
    Hi JPM, have you solve this issue?, I am facing same issue so it can be helpful if you have any idea. – Pankaj K. Nov 21 '18 at 06:23

0 Answers0