我试图将我的通知状态栏图标设置为动画 android.R.drawable.stat_sys_upload,它工作正常,但图标没有动画:
private void showStatusNotification() {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setAutoCancel(false);
notificationBuilder.setOngoing(true);
notificationBuilder.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this,
MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT));
notificationBuilder.setContentTitle(getString(R.string.notification_title));
notificationBuilder.setContentText(getString(R.string.notification_text));
notificationBuilder.setSmallIcon(android.R.drawable.stat_sys_upload);
notificationManager
.notify(STATUS_NOTIFICATION_ID, notificationBuilder.build());
}
最佳答案
解决方案很简单,但非常棘手。你只需要添加
notificationBuilder.setTicker(getString(R.string.notification_ticker));
奇迹发生了,你的图标变成了动画。它与此错误有关:
http://code.google.com/p/android/issues/detail?id=15657
希望对大家有帮助。
关于Android - 显示动画状态栏图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15311135/