十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Android应用中怎么实现通知栏闪动效果?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

显示通知代码:
private void showNotification(Context ctx, String url) {
Notification n = new Notification();
n.flags |= Notification.FLAG_SHOW_LIGHTS;
n.flags |= Notification.FLAG_AUTO_CANCEL;
n.defaults = Notification.DEFAULT_SOUND;
n.icon = R.drawable.ic_launcher;
n.when = System.currentTimeMillis();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(ctx.getPackageName(), MainActivity.class.getName());
PendingIntent pi = PendingIntent.getActivity(ctx, 0, intent, 0);
n.setLatestEventInfo(ctx, "title", "summary", pi);
NotificationManager manager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, n);
}