차량 준비
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 섹션에서는 예약된 작업을 위해 차량을 준비하는 방법을 보여줍니다. 백엔드에서 차량을 작업에 매칭하려면 다음 단계를 각각 완료해야 합니다.
리스너 설정
Driver SDK는 백그라운드에서 작업을 실행하므로 오류, 경고, 디버그 메시지와 같은 특정 이벤트가 발생할 때 DriverStatusListener
를 사용하여 알림을 트리거하세요. 오류는 일시적일 수도 있고 (예: BACKEND_CONNECTIVITY_ERROR
) 위치 업데이트가 영구적으로 중지될 수도 있습니다. 예를 들어 VEHICLE_NOT_FOUND
오류가 표시되면 구성 오류를 나타냅니다.
다음 예는 DriverStatusListener
구현을 보여줍니다.
class MyStatusListener implements DriverStatusListener {
/** Called when background status is updated, during actions such as location reporting. */
@Override
public void updateStatus(
StatusLevel statusLevel, StatusCode statusCode, String statusMsg, @Nullable Throwable cause) {
// Existing implementation
if (cause != null && cause instanceof StatusRuntimeException) {
if (Status.NOT_FOUND.getCode().equals(cause.getStatus().getCode())) {
// NOT_FOUND gRPC exception thrown by Fleet Engine.
}
}
}
}
DriverContextBuilder.setDriverStatusListener(new MyStatusListener());
위치 업데이트 사용 설정
*VehicleReporter
인스턴스가 있으면 다음과 같이 위치 업데이트를 사용 설정합니다.
자바
DeliveryVehicleReporter reporter = ...;
reporter.enableLocationTracking();
Kotlin
val reporter = ...
reporter.enableLocationTracking()
(선택사항) 업데이트 간격 설정
기본적으로 Driver SDK는 10초 간격으로 위치 업데이트를 전송합니다. 각 위치 업데이트는 차량이 온라인 상태임을 나타내기도 합니다. reporter.setLocationReportingInterval(long, TimeUnit)
를 사용하여 이 간격을 변경할 수 있습니다. 지원되는 최소 업데이트 간격은 5초입니다. 업데이트를 더 자주 실행하면 요청이 느려지고 오류가 발생할 수 있습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-09-10(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-09-10(UTC)"],[[["\u003cp\u003eBefore tasks can be assigned, vehicles must be prepared by completing setup steps that enable communication with the backend system.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eDriverStatusListener\u003c/code\u003e is implemented to receive notifications regarding the vehicle's status, including errors, warnings, and debug messages.\u003c/p\u003e\n"],["\u003cp\u003eLocation updates are enabled using the \u003ccode\u003eenableLocationTracking()\u003c/code\u003e method of a \u003ccode\u003e*VehicleReporter\u003c/code\u003e instance, ensuring the backend knows the vehicle's position.\u003c/p\u003e\n"],["\u003cp\u003eOptionally, the frequency of location updates can be customized, but it's recommended to keep it at the default 10-second interval or above to avoid performance issues.\u003c/p\u003e\n"]]],[],null,[]]