Android應(yīng)用中怎么實(shí)現(xiàn)通知欄閃動(dòng)效果?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
顯示通知代碼:
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); }