Snapshot API 개요
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Snapshot API를 사용하여 사용자의 현재 환경에 관한 정보를 가져올 수 있습니다. Snapshot API를 사용하면 다양한 문맥 신호에 액세스할 수 있습니다.
- 걷거나 운전할 때와 같이 감지된 사용자 활동
- 등록한 주변 비콘
- 헤드폰 상태(연결 여부)
- 위도와 경도를 포함하는 위치입니다.
시스템은 이러한 값을 빠르게 반환할 수 있도록 캐시합니다. 데이터가 없으면 감지 및 추론이 실행되어 최신 상태 값을 반환합니다.
Awareness API는 공개 API가 있는 컨텍스트 유형의 기존 데이터 유형을 반환합니다.
각 컨텍스트 신호에는 해당하는 Snapshot API 메서드가 있습니다. 예를 들어 현재 감지된 활동을 가져오려면 getDetectedActivity()
를 호출하고 SuccessListener
를 사용하여 DetectedActivityResponse
를 가져온 다음 getActivityRecognitionResult()
를 호출하여 실제 요청 데이터를 가져올 수 있는 ActivityRecognitionResult
을 반환합니다.
다음 예는 감지된 최신 활동을 가져오는 방법을 보여줍니다.
Awareness.getSnapshotClient(this).getDetectedActivity()
.addOnSuccessListener(new OnSuccessListener<DetectedActivityResponse>() {
@Override
public void onSuccess(DetectedActivityResponse dar) {
ActivityRecognitionResult arr = dar.getActivityRecognitionResult();
}
})
요청 데이터로 할 수 있는 작업에 관한 자세한 내용은 스냅샷 데이터 가져오기를 참고하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThe Places and Weather contextual signals within the Awareness API are deprecated and have been turned off, with existing implementations restricted until specified dates.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers should utilize the Places SDK for Android instead of the Places contextual signal for new implementations.\u003c/p\u003e\n"],["\u003cp\u003eGoogle does not offer alternative functionality for the Weather contextual signal, impacting existing implementations relying on it.\u003c/p\u003e\n"],["\u003cp\u003eThe Awareness API continues to provide other contextual signals through the Snapshot API, including user activity, nearby beacons, headphone state, and location.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access these signals using corresponding Snapshot API methods and retrieve relevant data for their applications.\u003c/p\u003e\n"]]],[],null,["# Snapshot API overview\n\n**Deprecation notice: Places and Weather contextual signals** **Warning:**\n| The Places and Weather contextual signals, exposed by the\n| [`getPlaces()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getPlaces()), and\n| [`getWeather()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getWeather())\n| methods, were deprecated.\n|\n| - The Places contextual signal was turned off. Continued use of this signal was restricted to customers with existing implementations, through October 30, 2019. New implementations must use the [Places SDK for Android](/places/android-sdk) instead of the Places contextual signal.\n| - The Weather contextual signal has also been turned off. Continued use of this signal has been restricted to customers with existing implementations, through January 31, 2020. Google doesn't offer alternative functionality for the Weather contextual signal.\n\nYou can use the [Snapshot API](/android/reference/com/google/android/gms/awareness/Awareness#getSnapshotClient(android.app.Activity))\nto get information about the user's current environment. With the Snapshot API,\nyou can access a variety of [context signals](/awareness/overview#context-types):\n\n- Detected user activity, such as when they walk or drive.\n- Nearby beacons that you've registered.\n- Headphone state, plugged in or not.\n- Location, which includes latitude and longitude.\n\nThe system caches these values so that they can be returned quickly. If there's\nno data, sensing and inference are performed to return fresh state values.\nThe Awareness API returns the existing data type for context types that have a\npublic API.\n\nEach context signal has a corresponding Snapshot API method. For example, to\nget the current detected activity, you call\n[`getDetectedActivity()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getDetectedActivity()),\nuse a `SuccessListener` to get a [`DetectedActivityResponse`](/android/reference/com/google/android/gms/awareness/snapshot/DetectedActivityResponse),\nthen call [`getActivityRecognitionResult()`](/android/reference/com/google/android/gms/awareness/snapshot/DetectedActivityResponse#getActivityRecognitionResult())\nto return an [`ActivityRecognitionResult`](/android/reference/com/google/android/gms/location/ActivityRecognitionResult)\nfrom which you can get the actual request data.\n\nThe following example shows how to get the latest detected activity: \n\n Awareness.getSnapshotClient(this).getDetectedActivity()\n .addOnSuccessListener(new OnSuccessListener\u003cDetectedActivityResponse\u003e() {\n @Override\n public void onSuccess(DetectedActivityResponse dar) {\n ActivityRecognitionResult arr = dar.getActivityRecognitionResult();\n }\n })\n\nFor more information about what you can do with the request data, see\n[Get Snapshot data](/awareness/android-api/snapshot-get-data)."]]