Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control frequency of notification update on locked screen

I have an application which updates a notification through a service.

This notification is updated every second. It shows a timer.

Currently on nougat, with device locked, notification update triggers screen to wake up, to show the updated notification.

I would like to control this as my notification is really frequent.

I would also like to avoid changing the update frequency of the notification. Doing so shows less accurate information to the user.

So what I am looking for is a programmatic way to control wake up screen frequency upon notification updates.

thank you :)

like image 901
unludo Avatar asked May 26 '17 10:05

unludo


People also ask

How do I turn off notifications on lock screen until unlocked?

Go to Settings > Lock Screen > Notifications > On > Hide Content > On. This will show notifications on your lock screen without any previews or additional content. Alternatively, disable Lock Screen Notifications completely and go to Settings > Notifications > Status Bar > All Notifications. Hope this helps.


1 Answers

This below notification can be used to update the user frequently and also the screen will not wake up when locked up. you may try

if(notificationBuilder == null) {
             notificationBuilder =
                     new NotificationCompat.Builder(MainActivity.this)
                             .setSmallIcon(R.mipmap.ic_launcher)
                             .extend(wearableExtender)
                             .setAutoCancel(true)
                             .setContentTitle("Random Notification")
                             .setContentText("Appears!")
                             .setOnlyAlertOnce(true)
                             .setOngoing(true)
                             .setVisibility(Notification.VISIBILITY_PUBLIC)
                             .setContentIntent(contentIntent);
         }else{
             notificationBuilder.setContentText("change this to current updated text");
         }
            NotificationManagerCompat notificationManager = NotificationManagerCompat.from(MainActivity.this);

            notificationManager.notify(888, notificationBuilder.build());
like image 186
Vishnu Prasad Avatar answered Sep 17 '22 23:09

Vishnu Prasad