M
MBPower
Fortgeschrittenes Mitglied
- 11
Ich würde gerne eine Status Notification erstellen und bei dieser dann in regelmässigen Abständen den text und title verändern.
Wie kann ich bei der folgenden Notification text und title verändern, ohne diese immer komplett neu zu erstellen?
Wie kann ich bei der folgenden Notification text und title verändern, ohne diese immer komplett neu zu erstellen?
Code:
private void creatNotification(){
notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.notification;
String Message = "Ticker Nachricht";
long displayTime = System.currentTimeMillis();
notification = new Notification(icon, Message, displayTime);
notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
contentView.setImageViewResource(R.id.image, R.drawable.icon);
contentView.setTextViewText(R.id.title, "Text 1"));
contentView.setTextViewText(R.id.text, "Text 2");
notification.contentView = contentView;
Intent intent = new Intent(this, test.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0, intent, 0);
notification.contentIntent = pendingIntent;
}
Code:
notificationManager.notify(1, notification);