title: Receiver stopped receiving in Oreo
body: <p>I understand services and such are being clamped down on, so my receiver has stopped working in Android Oreo.</p>
  
  <p>I have this code starting the service -</p>
  
  <pre><code>Intent intent = new Intent(this, MyService.class);
  intent.putExtra("Time", locationUpdatesTime);
  intent.putExtra("Dist", locationUpdatesDistance);
  startService(intent);
  </code></pre>
  
  <p>I have this in my service -</p>
  
  <pre><code>Intent intent = new Intent();
  intent.setAction("com.androidandyuk.laptimerbuddy");
  intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
  intent.putExtra("Lat", thisLat);
  intent.putExtra("Lon", thisLon);
  
  sendBroadcast(intent);
  </code></pre>
  
  <p>But my receiver is never called.  Having searched around I think I have to register my receiver, but I can't figure how I code this with the correct syntax. Can anyone help please?</p>
  
  <p>If you wish to downvote me, I'd appreciate if you would comment why, so I can learn as I've looked for an answer, couldn't find/understand it and I think I've laid the question out as I should :-)</p>
  
  <p>Many thanks!</p>
  
  <p><strong>UPDATE</strong> Trying to use a LocalBroadcastManager.</p>
  
  <p>In MainActivity I have -</p>
  
  <pre><code>BroadcastReceiver mMessageReceiver;
  </code></pre>
  
  <p>onCreate I have -</p>
  
  <pre><code>mMessageReceiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              // Get extra data included in the Intent
              String message = intent.getStringExtra("message");
              Log.i("receiver", "Got message: " + message);
          }
      };
      LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("custom-event-name"));
  </code></pre>
  
  <p>In my service, onLocationChanged</p>
  
  <pre><code>    Log.i("sender", "Broadcasting message");
                  Intent intent = new Intent();
                  intent.setAction("custom-event-name");
                  intent.putExtra("message", "This is my message!");
  
   LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
  </code></pre>
  
  <p>This works as I see the sender message.</p>
  
  <p>What am I doing wrong?</p>