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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -