3
Intent intentCancel = new Intent(getApplicationContext(), MainActivity.class);
intent.putExtra(MainActivity.UPLOAD_CANCELED, true);
PendingIntent pendingIntent = PendingIntent.getBroadcast(Service.this, 0, intentCancel, 0);
builder = new NotificationCompat.Builder(Service.this);
builder.setOngoing(true);
builder.setContentTitle("Uploading");
builder.addAction(R.mipmap.ic_ab_close, "Cancel", pendingIntent);
builder.setProgress(100,0, false); 
notificationManager.notify(idNotification, builder.build());

This is my code to create a Notification. This will be updated acoording to a HTTP Request that uploads a file to my webserver. This is the progress callback method:

public void progress(int current, int total) {
    if (notificationManager != null && builder != null) {
        builder.setProgress(total, current, false);
        notificationManager.notify(idNotification, builder.build());
    }
}

The problem is: When that progressbar is being updated fast as file upload, I can not tap on Cancel button.

Should be the upload method is so fast than the notification keep always reconstructing, this way tapping is never enabled?

P.S.: When progress finishes, cancel button is "tappable".

What could I do to fix that?

Related questions:

Android notification progressbar freezing

Huge memory usage in notifications

Community
  • 1
  • 1
richardaum
  • 6,651
  • 12
  • 48
  • 64

0 Answers0