1

I have two intent services: 1. receives location updates in the background using Fused Location API. 2. Receives Activity Recognition in the background using Activity Recognition API.

whenever i detect that the user is standing still i want to be able to change the priority of fused location from PRIORITY_HIGH_ACCURACY to PRIORITY_BALANCED_POWER_ACCURACY.

I heard about removeLocationUpdates() and then calling to requestLocationUpdates() but i cant use that since im only running intent services without activity in the background.

Any help would be helpful.

WoW
  • 151
  • 2
  • 10
  • Why can't you call `requestLocationUpdates()` from within your activity recognition `IntentService`? – ianhanniballake May 01 '15 at 18:46
  • Because GoogleApiClient is not connected there and the intent service doesnt know about GoogleApiClient Object at all ... is ther any way i can send that object from the activity to the intent service? – WoW May 01 '15 at 18:49

1 Answers1

1

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 requestLocationUpdates() directly when you need to.

Note the comment on requestLocationUpdates() Javadoc:

Any previously registered requests that have the same PendingIntent (as defined by equals(Object)) will be replaced by this request.

So there should not be a need to call removeLocationUpdates().

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Thanks ... So you are saying to make a new connection to GoogleApiClient in the Activity Recognition intent service and just to request whenever i need to ? – WoW May 02 '15 at 07:24