Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android wear notification on top

I want that my notification appears on top of all existing notification stack on android wear device. I read a documentation, google says that we have to use method setPriority() for this notification to change notification position within notification statck. I have implemented notification like this:

NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .extend(wearableExtender)
            .setContentTitle(getSpannableTitle(flightDto.getFlightName()))
            .setContentText(getSpannableContentText(flightDto, color, status))
            .setPriority(NotificationCompat.PRIORITY_MAX);

But this code doesn't as needed, if calendar notification is on top of all, my notification appears below calendar notification. How to show this notification on top of all notifications?

like image 828
Volodymyr Avatar asked Dec 20 '22 09:12

Volodymyr


1 Answers

To show your notification on top of all notifications except setPriotity you have to add setVibrate method. Here working code sample:

NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .extend(wearableExtender)
            .setContentTitle(getSpannableTitle(flightDto.getFlightName()))
            .setContentText(getSpannableContentText(flightDto, color, status))
            .setPriority(priority)
            .setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
like image 152
Volodymyr Avatar answered Jan 05 '23 09:01

Volodymyr