title: Using startForeground with android service
body: <p>I have found this Question : <a href="https://stackoverflow.com/questions/24839655/how-to-use-startforeground">How to use startForeground?</a> in Stackoverflow and as it says in the command from the top answer the notification constructor and <code>setLastEventInfo</code> is deprecated. I know that's a duplicated post but the other post is 4 years old and has no answer in the commends so I thought i try do ask it again maybe someone can help me with this. </p>
  
  <p>Code:</p>
  
  <pre><code>Notification note = new Notification(R.drawable.ic_launcher,
          "Foreground Service notification?", System.currentTimeMillis());
  Intent i = new Intent(this, CurrentActivity.class);
  i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
          | Intent.FLAG_ACTIVITY_SINGLE_TOP);
  PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
  Date dateService=new Date(System.currentTimeMillis());
  String dateString=dateService.toString().split(" ")[1]+" "+dateService.toString().split(" ")[2]+" "+dateService.toString().split(" ")[3];
  note.setLatestEventInfo(this, "Foreground service",
          "Now foreground service running: "+dateString, pi);
  note.flags |= Notification.FLAG_AUTO_CANCEL;
  
  startForeground(2337, note);
  </code></pre>