我有一种方法可以让状态栏中的图标闪烁,从级别列表中获取图像。状态栏未展开时,图像闪烁。但是当状态栏被展开时(即在状态窗口中),该图像不会闪烁。我错过了什么吗?
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();
}
这是关卡列表文件:
<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" />
我从这里将其设置到通知栏:
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);