Android – 显示动画状态栏图标

前端之家收集整理的这篇文章主要介绍了Android – 显示动画状态栏图标前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将我的通知状态栏图标设置为动画 android.R.drawable.stat_sys_upload,它工作正常,但图标不动画:
  1. private void showStatusNotification() {
  2.  
  3. NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  4.  
  5. Builder notificationBuilder = new NotificationCompat.Builder(this);
  6. notificationBuilder.setAutoCancel(false);
  7. notificationBuilder.setOngoing(true);
  8. notificationBuilder.setContentIntent(PendingIntent.getActivity(this,new Intent(this,MainActivity.class),PendingIntent.FLAG_UPDATE_CURRENT));
  9. notificationBuilder.setContentTitle(getString(R.string.notification_title));
  10. notificationBuilder.setContentText(getString(R.string.notification_text));
  11. notificationBuilder.setSmallIcon(android.R.drawable.stat_sys_upload);
  12. notificationManager
  13. .notify(STATUS_NOTIFICATION_ID,notificationBuilder.build());
  14. }

解决方法

解决方案很简单,但非常棘手.你只需要添加
  1. notificationBuilder.setTicker(getString(R.string.notification_ticker));

魔术发生了,你的图标也是动画的.它与这个bug有关:

@L_404_1@

希望它可以帮到某人.

猜你在找的Android相关文章