I am using bellow code to show a notification on my Android phone. I want to reduce the time which uses to shows the notification. Now, it spends about 2 seconds for showing, then it is hidden. I want to reduce the time from 2 seconds to 1 second. Is it possible?
Notification notification = new NotificationCompat.Builder(context)
.setContentTitle(context.getString(R.string.app_name))
.setContentText("Notification")
.setAutoCancel(false)
.setPriority(Notification.PRIORITY_MAX)
.setSmallIcon(R.mipmap.ic_launcher)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
.build();
NotificationManager notificationManager = getNotificationManager(context);
notificationManager.notify(SAFER_DISCONNECTED_NOTIFICATION_ID, notification);
Now, it spends about 2 seconds for showing, then it is hidden.
There is no particular guarantee regarding the amount of time that a Notification
will be shown in heads-up mode, which I assume is what you are referring to.
For example, by default it will be shown for 0 seconds on Android 4.4 and earlier, which does not natively support heads-up notifications. However, a user could install an app with a NotificationListenerService
, and that service could display the notification however, and for however long, it wants.
Is it possible?
No, sorry. That is under the control of the code that displays the notifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With