android - Prevent notification from being swiped off tray -
is possible prevent notification being swiped out of notification tray? usb notifications. if not, there sort of listener 1 can implement scenario?
you can making notifications sticky
private void makenotification(context context) { intent intent = new intent(context, mainactivity.class); pendingintent pendingintent = pendingintent.getactivity(context, notification_id, intent, pendingintent.flag_update_current); notification.builder builder = new notification.builder(context) .setcontenttitle("notification title") .setcontenttext("sample notification content") .setcontentintent(pendingintent) .setsmallicon(r.drawable.ic_action_picture) .setlargeicon(bitmapfactory.decoderesource(getresources(), r.drawable.ic_launcher)) ; notification n; if (build.version.sdk_int >= build.version_codes.jelly_bean) { n = builder.build(); } else { n = builder.getnotification(); } n.flags |= notification.flag_no_clear | notification.flag_ongoing_event; notificationmanager.notify(notification_id, n);
}
Comments
Post a Comment