Android - 显示动画状态栏图标

标签 android android-notifications

我试图将我的通知状态栏图标设置为动画 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/

相关文章:

android - getoutputmediafileuri 方法不可访问?

android - setLatestEventInfo() 无法在 Android Studio 中解析

Android Phonegap GCM 多重通知

android - 自定义通知未在 Android 中显示

android - 如何在将在 RemoteView 中使用的可绘制对象上设置滤色器?

android - 导航组件 : Get Activity Result

android - 如何在没有嵌套 ScrollView 的情况下实现新 Material gmail 工具栏?

android - Firebase Android - startAt() 和 endAt() 无法正常工作?

android - 为什么我的应用程序在快速切换 fragment 时崩溃?

android - 服务内的 BroadcastReceiver 未处理通知操作的广播