android - Swipe dismissing service notification -
thought wouldn't problem @ all, still. service notification doesn't want swipe-dismiss no matter do.
i have progress notification, started in service using startforeground(id, notification). here how build it:
public notification createerrornotification(string message) { notificationcompat.builder builder = new notificationcompat.builder(getapplicationcontext()); intent showappintent = new intent(getapplicationcontext(), mainactivity.class); showappintent.setaction(intent.action_main); showappintent.addcategory(intent.category_launcher); pendingintent pendingshowappintent = pendingintent.getactivity(getapplicationcontext(), 10, showappintent, pendingintent.flag_cancel_current); builder.setcontenttitle(getstring(r.string.label_download_error)) .setwhen(0) .setcontenttext(message) .setcontentintent(pendingshowappintent) .setautocancel(true) .setongoing(false) .setsmallicon(r.drawable.ic_launcher); return builder.build(); }
at point if error occurs, replace progress notification described error notification, disabling 'ongoing' , other stuff. stop service completely:
private void stopservice() { stopself(); taskthread.stoplooper(); downloadhandler.stopexecution(); downloadhandler = null; taskthread = null; }
and call
stopforeground(false);
false - because want notification kept on screen , dismissed user. swipe-dismissing doesn't work.
if call stopforeground(true) - notification correctly removed.
anyone has ideas doing wrong here?
as @orium have suggested, resolve issue need stop services in foreground mode removing notification, , create new notification using same id, settings set dismissable. be: stopforegound(true) , create notification setautocancel(true)
Comments
Post a Comment