Android ongoing notification - auto collapse/hide/minimize to status bar only (not cancel) -
i'm building ongoing notification. when notification fired - shows on top of display until user swipes it, , notification displayed in status bar.
how can set timer notification automatically collapsed in status bar? e.g. user won't need swipe in order remove main display? not cancel - minimize status bar.
the code below contains ongoing notification it's properties, , 2 actions: click on body open app, click on button close notification.
intent innerintent = new intent(context, mainactivity.class); pendingintent notificationpendingintent = pendingintent.getactivity(context, 0, innerintent, pendingintent.flag_update_current); intent dismissintent = new intent(context, exitservice.class); pendingintent pidismiss = pendingintent.getservice(context, 0, dismissintent, pendingintent.flag_update_current); android.support.v4.app.notificationcompat.builder mbuilder = new notificationcompat.builder(context) .setsmallicon(r.mipmap.ic_launcher) .setcontenttitle(context.getstring(r.string.app_name)) .setcontenttext(context.getstring(r.string.ongoing_short_text)) .setcategory(notification.category_service) .setpriority(notification.priority_max) .setvisibility(notification.visibility_private) .setcontentintent(notificationpendingintent) .setautocancel(true) .setonlyalertonce(true) .setlights(context.getresources().getcolor(r.color.primary), 50, 10000) .setsound(ringtonemanager.getdefaulturi(ringtonemanager.type_notification)) .setvibrate(new long[]{0, 50}) .setongoing(true) .setstyle(new notificationcompat.bigtextstyle().bigtext(context.getstring(r.string.ongoing_long_text))) .addaction(r.mipmap.ic_stop, context.getstring(r.string.dismiss), pidismiss); int mnotificationid = ongoing_notification_id; notificationmanager mnotifymgr = (notificationmanager) context.getsystemservice(context.notification_service); mnotifymgr.notify(mnotificationid, mbuilder.build());
Comments
Post a Comment