简体   繁体   English

展开状态栏时,为什么图像不闪烁?

[英]Why is the image not blinking when Status Bar is expanded?

I have a method to make the icon blink in the status bar that takes image from a level list. 我有一种方法可以使状态栏中的图标闪烁,从而从级别列表中获取图像。 The image blinks when the status bar is not expanded. 当状态栏未展开时,图像闪烁。 But this image does not blink when the status bar is expanded (ie in the status window). 但是当状态栏展开时(即在状态窗口中),该图像不会闪烁。 Am I missing something? 我想念什么吗?

private void startIconBlink(final int notificationId, Notification notifyDetails, final String notificationTimestamp)
{
    notifyDetails.defaults = 0;
    final Notification notification = notifyDetails;
    new Thread(){
        public void run()
        {
            int i = 0;
            try{
                while(i < 30)
                {
                    //If notification has been raised again, then stop this thread.
                    if(!(notificationIdHashTable.get(notificationId + "").equals(notificationTimestamp)))
                    {
                        break;
                    }

                    if(i%2 == 0)
                    {
                        notification.iconLevel = 0;
                        //
                    }
                    else {
                        notification.iconLevel = 1;
                        //mNotificationManager.cancel(notificationId);
                    }

                    mNotificationManager.notify(notificationId, notification);

                    i++;
                    Thread.sleep(1000);
                }
            }catch (Exception e) {
                // TODO: handle exception

                e.printStackTrace();
            }
        }
    }.start();
}

This is the level list file: 这是级别列表文件:

<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="0" android:drawable="@drawable/alert1" />
<item android:maxLevel="1" android:drawable="@drawable/alert2" />

I am setting it to the notification bar from here: 我将其从此处设置为通知栏:

int imageIcon=R.drawable.level_list ;
RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.notification_layout);
                notifyDetails.contentView = contentView;
                notifyDetails.contentIntent = myIntent;
                notifyDetails.contentView.setTextViewText(R.id.title,messageTitle);
                notifyDetails.contentView.setTextViewText(R.id.text, message);
                notifyDetails.contentView.setImageViewResource(R.id.icon, imageIcon);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM