Как обновить текст уведомления для службы переднего плана в Android?

У меня настроена служба переднего плана в Android. Я хочу обновить текст уведомления. Я создаю службу, как показано ниже.

Как я могу обновить текст уведомления, который настроен в этой службе переднего плана? Как лучше всего обновить уведомление? Приветствуется любой пример кода.

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);

    }

Я создаю службу в своей основной деятельности, как показано ниже:

    // Start Notification Service
    Intent serviceIntent = new Intent(this, NotificationService.class);
    startService(serviceIntent);
123
задан Luke 3 April 2011 в 07:41
поделиться