2

I was wondering what I could use to replace the deprecated Notification class and the setLatestEventInfo() method. It's not recognizing the setLatestEventInfo() method.

Here is the current code I have:

public void makeForeground() {
  Notification notification = new Notification(R.drawable.icon, getText(R.string.servicename), System.currentTimeMillis());
  notification.setLatestEventInfo(this, getText(R.string.servicename), this.lang[134], PendingIntent.getActivity(this, 0, new Intent(this, UIActivity.class), 0));
  startForeground(2, notification);
}

What can I replace this with?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
user268397
  • 1,917
  • 7
  • 38
  • 56
  • 2
    Possible duplicate of: http://stackoverflow.com/questions/32450449/setlatesteventinfo-cannot-be-resolved – REG1 Jun 17 '16 at 21:53

1 Answers1

1

You can use NotificationCompat for replacing Notification.

You can read it here more:

  1. https://developer.android.com/guide/topics/ui/notifiers/notifications.html
  2. https://developer.android.com/training/notify-user/build-notification.html
  3. https://developer.android.com/reference/android/support/v4/app/NotificationCompat.html
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • can you provide me an example for starting Foreground service. They are still using setLatestEventInfo on documentation site. – Myat Min Soe Jul 11 '16 at 09:58