title: Google Play Services: how to check if there is currently "active" pending intent callback registered to location updates/activity recognition?
body: <p>my application perform periodic location updates and Activity recognition detection in background.</p>
  
  <p>I'm doing that using the Google Play Services API's:  </p>
  
  <p>for example - to register to location updates, I provide pending intent to receive update:</p>
  
  <pre><code>mLocationClient.requestLocationUpdates(mLocationRequest, pendingInent);
  </code></pre>
  
  <p>to unregister to location update, I'm doing the following:</p>
  
  <pre><code>mLocationClient.removeLocationUpdates(pendingInent);
  </code></pre>
  
  <p>that's nice, and working great.</p>
  
  <p><strong>but how can I find out if there is  currently a  pendingIntent holding Intent to my application's component is currently registered in front of Google play services to receive location updates or not?</strong> </p>
  
  <p>I notices that there is no API to check this, and the <a href="https://stackoverflow.com/questions/4556670/how-to-check-if-alarmmamager-already-has-an-alarm-set">approach to check for pendingIntent existence</a> seems not to work for API's against google play services - the pending intent stays exists even after I call the <code>removeLocationUpdates()</code> method.</p>
  
  <p>I know I can save state (to shared preferences) indicating if now I'm registered or not, but it's not the right solution, and will be "buggy" because it can happen that google play process went down, lost the pendingIntent, but my process will still think that the location updates are "active"..</p>
  
  <p><strong>same problem exactly exists for the activity recognition updates.</strong></p>
  
  <p>Just to make it clear, all I want to do is provide to the users of my application ability to know if my app is currently collecting data in background or not, and provide them a way to toggle between that.  So if there is other way to do that <strong>in reliable way</strong> - I'll except it as an answer also  </p>
  
  <p>reliable way = knowing if currently the pending intent really registered in from of google play services...</p>
  
  <ul>
  <li>using <code>LocationListener</code> is not an option for me, because I must be able to receive updates event when my process is shout down - what's possible only using <code>PendingIntent</code> callback..</li>
  </ul>
  
  <p>Thanks in advance.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>this is the pendintIntent I provide to register and unregister to location updates:</p>
  
  <pre><code>Intent locationUpdatesIntent = new Intent(context, LocationUpdatesIntentService.class);
  PendingIntent pendingInent = PendingIntent.getService(context, 0, locationUpdatesIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  </code></pre>
  
  <p>and this is how I'm trying to check (unsuccessfully) if it registered or not:</p>
  
  <pre><code>Intent locationUpdatesIntent = new Intent(context, LocationUpdatesIntentService.class);
  PendingIntent pendingInent = PendingIntent.getService(context, 0, locationUpdatesIntent, PendingIntent.FLAG_NO_CREATE);
  boolean isLocationUpdatesEnabled = (pendingIntent != null);
  </code></pre>
  
  <p><code>isLocationUpdatesEnabled</code>  returns true event after I call <code>removeLocationUpdates()</code></p>