Android 更新通知tickerText
我在后台服务中创建了一个通知Android 更新通知tickerText,android,Android,我在后台服务中创建了一个通知 notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final Intent i = new Intent(this, MapsActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
final Intent i = new Intent(this, MapsActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
final PendingIntent pending = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
final Notification notification = new Notification.Builder(this)
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
.setTicker("text")
.setContentTitle("text")
.setContentText("text")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pending)
.setWhen(when)
.setAutoCancel(true).build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(1000, notification);
startForeground(1000, notification);
完成这些操作后,我想更新现有通知的tickerText、contentTitle和contentText。有可能吗 您可以[取消旧通知并显示新通知][1]。[1] :@Vang我可以创建一个与旧通知id相同的新通知?是的,你可以,然后它将被更新。我还必须编写
startForeground(…)
?似乎没有必要