I have a foreground setting in Android. I would like to update the notification text. I am creating a service as shown below.
How do I update the notification text that is configured in this front-end service? What is the best practice for updating notification? Any sample code would be appreciated.
public class NotificationService extends Service { private static final int ONGOING_NOTIFICATION = 1; private Notification notification; @Override public void onCreate() { super.onCreate(); this.notification = new Notification(R.drawable.statusbar, getText(R.string.app_name), System.currentTimeMillis()); Intent notificationIntent = new Intent(this, AbList.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); this.notification.setLatestEventInfo(this, getText(R.string.app_name), "Update This Text", pendingIntent); startForeground(ONGOING_NOTIFICATION, this.notification); }
I create a service in my main action, as shown below:
// Start Notification Service Intent serviceIntent = new Intent(this, NotificationService.class); startService(serviceIntent);
android service notifications foreground
Luke Apr 03 2018-11-11T00: 00Z
source share