title: How to keep a service running when it's swiped in recent tasks (Like pandora)
body: <p>When I swipe my app from recent tasks, my service stops, then restarts in a few seconds. I'd like it to behave more like pandora.</p>
  
  <p>When you're playing music with pandora and swipe pandora out of recent tasks, the music continues to play without stopping at all. I'm trying to implement this behavior in my app.</p>
  
  <p>I saw this post: <a href="https://stackoverflow.com/questions/3856767/android-keeping-a-background-service-alive-preventing-process-death">Android: keeping a background service alive (preventing process death)</a> which seems to indicate that the way to do this was to use the startForeground method.</p>
  
  <p>I copied this code from <a href="http://developer.android.com/guide/components/services.html#Foreground" rel="nofollow noreferrer">http://developer.android.com/guide/components/services.html#Foreground</a></p>
  
  <pre><code>    Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
          System.currentTimeMillis());
  Intent notificationIntent = new Intent(this, ExampleActivity.class);
  PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
  notification.setLatestEventInfo(this, getText(R.string.notification_title),
          getText(R.string.notification_message), pendingIntent);
  startForeground(ONGOING_NOTIFICATION_ID, notification);
  </code></pre>
  
  <p>And made sure that my notification id was not zero (it's 1). I also return START_STICKY. Any clue what I'm doing wrong?</p>
  
  <p>EDIT: The above behavior happens on 4.2. On 4.4, the notification doesn't go away. However, the thread I'm running inside the service stops and does not restart. At least on 4.2 it restarts :/</p>