title: Broadcast receiver stops registering broadcasts after a few seconds
body: <pre><code>@Override
  protected void onStart() {
      startService(new Intent(this, jam_service.class));
      super.onStart();
  </code></pre>
  
  <p>As soon as I create my main activity, I start my service that looks like this</p>
  
  <pre><code> @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      IntentFilter intentFilter = new IntentFilter(myBroadcastReceiver.BroadcastTypes.METADATA_CHANGED);
     IntentFilter(myBroadcastReceiver.BroadcastTypes.PLAYBACK_STATE_CHANGED);
      intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
  
      registerReceiver(broadcastReceiver, intentFilter);
      return START_STICKY;
  }
  </code></pre>
  
  <p>Which registers this broadcast receiver</p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {
      c.writeNewUser(intent.getStringExtra("track"),"user", intent.getStringExtra("track"));
  </code></pre>
  
  <p>The broadcast receiver detects when the user changes songs in Spotify, and it works sometimes for a short period of time after launching my app and then switching to Spotify, or when my app is open and changing Spotify songs from the notification bar. I want this receiver to never stop listening to broadcasts, even after my app has been in the background for a while. Why does it stop working? </p>