title: How can I reference a boolean variable from an intent (background service)?
body: <p>I have a background service <code>GpxService</code>:</p>
  
  <pre><code>public class GpxService extends Service implements LocationListener {
      public boolean is_recording;
      ...
  }
  </code></pre>
  
  <p>I am able to start this service as a background service in my MainActivity:</p>
  
  <pre><code>gpxService = new Intent(MainActivity.this, GpxService.class);
  gpxService.setAction(GpxService.START_SERVICE);
  // notification, startForeground, etc. managed within gpxService onStartCommand
  startService(gpxService);
  </code></pre>
  
  <p><strong>How can I access the flag boolean <code>is_recording</code> in the Intent gpxService in the MainActivity?</strong></p>
  
  <hr>
  
  <p>Background: I have two buttons, <em>record</em> and <em>stop</em>. In the <code>onCreate</code> method of MainActivity, I use <code>setEnabled</code> to grey out one and leave the other clickable. I want which button is greyed and which is left clickable to depend on the boolean flag <code>is_recording</code> in the background service.</p>
  
  <p>I can't have <code>is_recording</code> in MainActivity since it is sometimes destroyed to clear memory. In this case, with the background service still running, reopening the app will reset the <code>is_recording</code> flag, triggering the if statement wrongly, and greying out the wrong button.</p>