android - Notification doesn't appear in foreground service -
i'm using following code:
private void startforeground(boolean isactive) { intent notificationintent = new intent(this, mainactivity.class); pendingintent pendingintent = pendingintent.getactivity(this, 1, notificationintent, pendingintent.flag_update_current); notification notification = new notificationcompat.builder(this) .setsmallicon(r.mipmap.ic_launcher) .setcontenttitle(getstring(isactive ? r.string.title_agent_active : r.string.title_agent_inactive)) .setcontentintent(pendingintent) .build(); startforeground(1, notification); }
and
@override protected void onhandleintent(intent intent) { startforeground(true); ...
with code notification not appear.
but if replace startforeground(...) notificationmanager.notify(...) — shows notification, so, think, @ least notification building code ok.
where problem?
if you're using intentservice
service destroyed onhandleintent()
method finishes execution , then, notification removed.
Comments
Post a Comment