한눈에 파악이 가능한 시계의 작은 폼 팩터 덕분에 Wear OS는 사용자 위치를 기록하고 보고하고 응답하는 앱에 가장 적합한 플랫폼입니다. 예를 들어, 사용자에게 거리, 속도, 방향에 관한 실시간 업데이트를 제공하는 앱을 빌드하거나 사용자의 주변 환경을 한눈에 파악할 수 있는 신호를 제공하는 앱을 빌드할 수 있습니다.
일부 시계에는 연결된 휴대전화가 없어도 위치 데이터를 검색하는 GPS 센서가 내장되어 있습니다. 시계 앱에서 위치 데이터를 요청하면 시스템은 가장 전력 효율이 높은 방법으로 휴대전화나 시계에서 위치를 가져옵니다. 따라서 시계에 GPS 센서가 없어도 위치 정보를 계속 가져올 수 있습니다.
overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)setContentView(R.layout.main_activity)if(!hasGps()){Log.d(TAG,"This hardware doesn't have GPS.")// Fall back to functionality that doesn't use location or// warn the user that location function isn't available.}}privatefunhasGps():Boolean=packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)
Java
protectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main_activity);if(!hasGps()){Log.d(TAG,"This hardware doesn't have GPS.");// Fall back to functionality that doesn't use location or// warn the user that location function isn't available.}...}privatebooleanhasGps(){returngetPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);}
연결 끊김 이벤트 처리
시계에 내장 GPS 센서가 없고 휴대전화와의 연결이 끊어지면 시계의 위치 데이터 스트림이 중단됩니다. 앱에서 일관된 데이터 스트림을 기대한다면 연결 중단을 감지하고, 사용자에게 경고하며, 위치 기능의 성능을 단계적으로 저하해야 합니다.
GPS 신호가 중단되면 사용자 시계의 마지막으로 알려진 위치를 검색할 수 있습니다. 마지막으로 알려진 위치 검색은 GPS 업데이트 위치를 가져올 수 없을 때와 시계에 내장 GPS가 없고 휴대전화와의 연결이 중단된 때 유용합니다. 자세한 내용은 마지막으로 알려진 위치 가져오기를 참고하세요.
일괄 호출을 통한 위치 플러시
일괄 호출을 사용하는 경우 화면이 다시 켜질 때 또는 대기 모드에서 돌아올 때 flushLocations()를 호출하여 일괄 위치를 등록된 모든 LocationListeners, LocationCallbacks, Pending Intents에 즉시 반환합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Detect location on Wear OS\n\nA watch's small, glanceable form factor makes Wear OS an ideal platform for apps\nthat record, report, and respond to user location. As examples, you can build\napps that give users real-time updates on their distance, speed, and direction,\nor provide glanceable cues about users' surroundings.\n\nFor more information, see [Build location-aware apps](/training/location).\n\nSome watches have a built-in GPS sensor that retrieves location data without\nrequiring a connected phone. When you request location data in a watch app, the\nsystem retrieves the location from either the phone or the watch using the most\npower-efficient method. So even without a GPS sensor in the watch, you can still\nget location information.\n\nTo reduce the effect of location data acquisition on battery life,\ncall\n[`setPriority()`](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.Builder#setPriority(int))\nwith the value\n[`PRIORITY_BALANCED_POWER_ACCURACY`](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#PRIORITY_BALANCED_POWER_ACCURACY).\nDifferent priority settings may\n[optimize chips differently](/guide/topics/location/battery#accuracy).\n\nWhen possible, conserve battery by asking for location no more\nthan once per minute using\n[`setInterval()`](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.Builder#public-locationrequest.builder-setintervalmillis-long-intervalmillis).\n\nAs described in the following sections, your app needs to [handle the loss of\nlocation data](#notFound) when a watch without a sensor becomes disconnected from a phone.\n\nChoose your method\n------------------\n\nThere are a couple of ways to provide location data to a Wear OS app. You can\nuse the [Fused Location Provider (FLP)](#fused) or\n[Wear Health Services (WHS)](/training/wearables/health-services). FLP is a\nGoogle Play services API.\n\nUse FLP in the following circumstances:\n\n- You want location data in the moment but not continuously, such as marking the location of a parked car.\n- You want location continuously but don't need the location history.\n\nUse WHS in the following circumstances:\n\n- You want data from other sensors or are likely to want data from other sensors in the future.\n- Your app is a workout or exercise app that needs to track location data over the course of a specific time interval.\n\n| **Note:** We recommend WHS for all workout tracking, as it is more power efficient.\n\nFor watches paired with iPhones, see\n[Location data for watches paired to iPhones](/training/wearables/apps/independent-vs-dependent#location-data-for-watches-paired-to-iphones).\n\nUse the Fused Location Provider\n-------------------------------\n\nOn a watch, get location data using the\n[`FusedLocationProviderClient`](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient).\nThe FLP may use location data from the phone. For more information, see\n[Create location services client](/training/location/retrieve-current#play-services).\n\nFor information about requesting location updates and continuously tracking a\nuser's location, see [Request location updates](/training/location/request-updates).\n| **Note:** When creating a `LocationRequest`, it's important to consider batching using the [`setMaxWaitTime()`](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#public-locationrequest-setmaxwaittime-long-millis) because it can consume less battery and give a more accurate location, depending on the device's hardware capabilities.\n\nDetect on-board GPS\n-------------------\n\nIf a user goes jogging with a watch that lacks a built-in GPS sensor and leaves\nthe paired phone behind, your watch app can't get location data through the\nconnected device. Detect this situation in your app and warn the user that\nlocation capabilities are unavailable.\n\nTo determine whether a watch has a built-in GPS sensor, call the\n[`hasSystemFeature()`](/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String))\nmethod with\n[`PackageManager.FEATURE_LOCATION_GPS`](/reference/android/content/pm/PackageManager#FEATURE_LOCATION_GPS).\nThe following code detects whether the watch has a built-in GPS sensor when you start an activity: \n\n### Kotlin\n\n```kotlin\noverride fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.main_activity)\n\n if (!hasGps()) {\n Log.d(TAG, \"This hardware doesn't have GPS.\")\n // Fall back to functionality that doesn't use location or\n // warn the user that location function isn't available.\n }\n}\n\nprivate fun hasGps(): Boolean =\n packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)\n```\n\n### Java\n\n```java\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.main_activity);\n\n if (!hasGps()) {\n Log.d(TAG, \"This hardware doesn't have GPS.\");\n // Fall back to functionality that doesn't use location or\n // warn the user that location function isn't available.\n }\n ...\n}\n\nprivate boolean hasGps() {\n return getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);\n}\n```\n\nHandle disconnection events\n---------------------------\n\nIf a watch has no built-in GPS sensor and loses connection to a phone, the watch\nloses its location data stream. If your app expects a constant stream of data,\nyour app must detect the loss of a connection, warn the user, and gracefully\ndegrade in functionality.\n\nAs with a mobile device, when you request location updates using\n[`FusedLocationProviderClient.requestLocationUpdates()`](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient#requestLocationUpdates(com.google.android.gms.location.LocationRequest,%20android.app.PendingIntent)), you pass in either a\n[`LocationCallback`](https://developers.google.com/android/reference/com/google/android/gms/location/LocationCallback#public-void-onlocationavailability-locationavailability-locationavailability) or a\n[`PendingIntent`](https://developer.android.com/reference/android/app/PendingIntent).\nBoth of these include the location information and the\n[`LocationAvailability`](https://developers.google.com/android/reference/com/google/android/gms/location/LocationAvailability)\nstatus.\n\nWhen using the `LocationCallback` option, override\n[`onLocationAvailability()`](https://developers.google.com/android/reference/com/google/android/gms/location/LocationCallback#public-void-onlocationavailability-locationavailability-locationavailability) to receive updates regarding location availability status.\n\nWhen using the `PendingIntent` option and an\n[`Intent`](/reference/android/content/Intent) is returned, extract the location\navailability status from the `Intent` using the\n[`LocationAvailability.extractLocationAvailability(Intent)`](https://developers.google.com/android/reference/com/google/android/gms/location/LocationAvailability#extractLocationAvailability(android.content.Intent))\nmethod.\n\nHandle location not found\n-------------------------\n\nWhen the GPS signal is lost, you can retrieve the last known location of the\nuser's watch. Retrieving the last known location is helpful when you can't get a\nGPS fix and when the watch lacks built-in GPS and loses its connection with the\nphone. For more information, see\n[Get the last known location](/training/location/retrieve-current).\n\nFlush location with batched calls\n---------------------------------\n\nIf you are using batched calls, call\n[`flushLocations()`](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient#public-taskvoid-flushlocations)\nwhen the screen comes back on or returns from ambient mode to\nimmediately return any batched locations to all registered `LocationListeners`,\n`LocationCallbacks`, and `Pending Intents`.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Optimize location for battery](/develop/sensors-and-location/location/battery)\n- [Create a notification {:#notification}](/develop/ui/views/notifications/build-notification)\n- [Detect when users start or end an activity](/develop/sensors-and-location/location/transitions)"]]