2

I have 2 apps that require background location. One is for Golfing, and one is for Sailing. In sailing you probably dont have the phone connected. In Golf it continuously connects and disconnects.

So what I found out is that the Wear OS simulator behaves differently from the Galaxy watch 4. On the simulator I get an update each 3 seconds. Now on the Galaxy watch 4 I get an update each 3 minutes when location is turned off on the Phone. When the location is turned on on the phone then I get an update each 3 seconds.

I have asked permissions for ACCESS_FINE_LOCATION and ACCESS_BACKGROUND_LOCATION. Ambient Mode Support is ON

In my preferred situation I receive an GPS update each second while the watch screen is on or off. Now I already tried several options to achieve this but it isn't working. I'm now at a point to think that the Galaxy Watch 4 with Wear OS just limits the GPS when the screen is off no matter what. Though, there are many workout apps that need background GPS for distance speed calculations so I can't imagine it isn't simply possible.

  1. In a ViewModel I started fusedLocationProviderClient.requestLocationUpdates I get an update each second when the screen is on. when the screen is off, no updates

  2. Starting a Service update each 3 seconds when screen is on. no updates when screen is off.

  3. Starting a service with broadcastreceiver: location update each 3 seconds when screen is on and update each 3 minutes when the screen is off.

  4. Start a service with an ongoing notification and ongoing activity Same results as 3

  5. Service with ongoing activity and wakelocks Same results as 3

I could share my code, but my primary question is. Is it possible to achieve my desired result and is it possible. A bonus would be a method to force use the WAtch GPS since it is essential in Golf as your phone is often 20 yards/meters away and the distance to the flag needs to be way more precise than that.

Nick Felker
  • 11,536
  • 1
  • 21
  • 35
  • 1
    since you mentioned workout apps, take a look at the new health api, it has the ability to track locations in the background as well and you probably don't need to care about your own service... i didn't try it yet but i use the step-counter from this api and it works perfectly: https://developer.android.com/training/wearables/health-services/active – Veit Apr 29 '22 at 19:46

1 Answers1

0

After a day of many trial and error i found the cause.

In my situation I had my Samsung Watch 4 and an Emulator in Android Studio. The galaxy watch was used in the Galaxy Wear app and the Emulator was paired in the Google Wear app. This causes a Conflict. I removed the Google Wear app from my phone and it started to work as expected.

Another thing I noticed is that when you run a service, it gets killed 30 seconds after the screen goes out. But, when your watch is on a Charger, that doesn't happen. As I often develop with the watch on the charges because the WIFI ADB debugging and GPS consume a lot of battery.