Android的 - 显示动画的状态栏图标 [英] Android - show animated status bar icon
本文介绍了Android的 - 显示动画的状态栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图把我的通知状态栏图标,动画android.R.drawable.stat_sys_upload,它工作正常,但是图标没有动画:
私人无效showStatusNotification(){
NotificationManager notificationManager =(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
构建notificationBuilder =新NotificationCompat.Builder(本);
notificationBuilder.setAutoCancel(假);
notificationBuilder.setOngoing(真正的);
notificationBuilder.setContentIntent(PendingIntent.getActivity(此,0,新的意向(这一点,
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));
,奇迹发生了,你的图标动画。它关系到这个错误:
<一个href="http://$c$c.google.com/p/android/issues/detail?id=15657">http://$c$c.google.com/p/android/issues/detail?id=15657
希望它可以帮助别人。
I'm trying to set my notification status bar icon as animated android.R.drawable.stat_sys_upload, it works fine, but the icon do not animate:
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());
}
解决方案
The solution is simple, but very tricky. You just need to add
notificationBuilder.setTicker(getString(R.string.notification_ticker));
the magic happens and your icon is animated. It is related to this bug:
http://code.google.com/p/android/issues/detail?id=15657
Hope it helps someone.
这篇关于Android的 - 显示动画的状态栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文