how to speed up notification update delays

129 views Asked by At

as mentioned in here: why notification update is so slow , the notification manager update is slow, I basically use the following lines of code to update the notificaiton on my music player:

 public Notification buildNotificationWithCurrentState(){
    NotificationCompat.Builder notif = NotificationCompat.Builder(context, ID)
                                       .setXXYYZZ(newDataReplaced) ....
    return notif.build();
 }
 Notification notification = buildNotificationWithCurrentState();
 mNotificationManager.notify( MUSIC_NOTIFICATION_ID, notification );

The need to build a new notification everytime comes with stuffs like song title or information changing with every user event. Now, it would be okay, ** only the notification updates were lagging ** , but while the above code executes, the whole UI lags. Its about a 100ms lag, according to my calculations, and that's really looking bad to me.

I tried doing this:

Thread mThread = new Thread(
                new Runnable() {
                    @Override
                    public void run() {
                        Notification notification = buildNotificationWithCurrentState();
                        mNotificationManager.notify( MUSIC_NOTIFICATION_ID, notification );
                    }
                }
        );
        mThread.start();  

and as dumb as it looks, it didn't work, the UI still lags, and I don't know why. How can I update the notification updates a bit faster? Any hooks or hacks, bells or whistles that I could twist to achieve a bit faster update?

0

There are 0 answers