Detect location on Wear OS

A watch's small, glanceable form factor makes Wear OS by Google an ideal platform
for apps that record, report, and respond to user location. As examples, you can
build apps that give users real-time updates on their distance, speed, and direction,
or provide glanceable queues about users' surroundings.

Some watches have a built-in GPS sensor that retrieves location data without
requiring a tethered phone. When you request location data in a watch app,
however, you don't have to worry
about where the location data originates; the system gets the data via the most
power-efficient method. However, as described in sections below, your app
does need to handle the loss of location data.

Detect on-board GPS

If a user goes jogging with a watch that lacks a built-in GPS sensor,
but leaves the paired phone behind, your watch app cannot get location data
through a tethered connection. Your app should detect the
situation and warn the user that location functionality is unavailable.

To determine if a watch has a built-in GPS sensor, use the
hasSystemFeature()
method. The following code detects whether the watch has
a built-in GPS sensor when you start an activity:

Handle disconnection events

If a watch has no built-in GPS sensor, the watch abruptly loses its location
data stream upon losing the tethered data connection to a phone.
If your app expects a constant stream of data,
your app must detect the loss of a connection, warn the user, and
gracefully degrade in functionality.

Handle location not found

When the GPS signal is lost, you can retrieve the last known location
of the user's watch.
Retrieving the last known location is helpful when you cannot get a GPS fix,
or when the watch lacks built-in GPS and loses its connection with the phone.
For more information, see
Getting the last known location.

Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.