0

Im using fused location API And i have 2 intent services:

The first intent service is registering GoogleApiClient Object. The second intent service is getting location updates frequently and does not using GoogleApiClient Object.

I want to call : LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient,pendingIntent);

from the service that is getting location updates to stop getting location immediately but i cant becuase mGoogleApiClient does not registered ther.

Im confused about the solution to this ? Any ideas?

WoW
  • 151
  • 2
  • 10
  • So register it there? – ianhanniballake May 17 '15 at 19:41
  • I thought about it but it's strange? cant we just register mGoogleApiClient in one service and use it in other services?? – WoW May 17 '15 at 19:42
  • If your `mGoogleApiClient` is created in a different `IntentService`, you wouldn't be able to use it anyways as an `IntentService` is destroyed immediately upon finishing `onHandleIntent()` and therefore probably doesn't even exist when your second `IntentService` runs. – ianhanniballake May 17 '15 at 20:03

1 Answers1

0

Your app can connect to GoogleApiClient in more than one place at the same time. It will be much easier on yourself to connect to a GoogleApiClient with blockingConnect() in your activity recognition IntentService such that you can call removeLocationUpdates() directly when you need to.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Thanks for the answer . I tryied to use this.stopSelf(); and in the other intent service that is registered to GoogleApiClient i removed location updates and it looks like it's working . I'll update after i'll check it soon . But your answer is accepted. – WoW May 17 '15 at 20:21