गाड़ी तैयार रखें
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस सेक्शन में, शेड्यूल किए गए टास्क के लिए वाहन को तैयार करने का तरीका बताया गया है. जब तक ये सभी चरण पूरे नहीं हो जाते, तब तक आपका बैकएंड किसी टास्क के लिए वाहन को मैच नहीं कर सकता.
लिसनर के तौर पर सेट अप करना
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
इंस्टेंस मिलने के बाद, जगह की जानकारी के अपडेट पाने की सुविधा को इस तरह चालू करें:
Java
DeliveryVehicleReporter reporter = ...;
reporter.enableLocationTracking();
Kotlin
val reporter = ...
reporter.enableLocationTracking()
(ज़रूरी नहीं) अपडेट का इंटरवल सेट करना
डिफ़ॉल्ट रूप से, Driver SDK हर 10 सेकंड में जगह की जानकारी के अपडेट भेजता है. हर लोकेशन अपडेट से यह भी पता चलता है कि वाहन ऑनलाइन है. reporter.setLocationReportingInterval(long, TimeUnit)
में जाकर, इस
इंटरवल को बदला
जा सकता है. अपडेट करने का कम से कम समय 5 सेकंड होना चाहिए. बार-बार अपडेट करने से, अनुरोधों को प्रोसेस करने में ज़्यादा समय लग सकता है और गड़बड़ियां हो सकती हैं.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-09-05 (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-05 (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,["# Get the vehicle ready\n\nThis section shows how to get the vehicle ready for scheduled tasks. You must\ncomplete each of the following steps before your backend can match a vehicle to\na task.\n\nSet up listener\n---------------\n\nSince the Driver SDK performs actions in the\nbackground, use the `DriverStatusListener` to trigger notifications when certain\nevents occur, such as errors, warnings, or debug messages. Errors can be\ntransient in nature (such as `BACKEND_CONNECTIVITY_ERROR`), or they might\ncause location updates to stop permanently. For example, if you receive a\n`VEHICLE_NOT_FOUND` error, it indicates a configuration error.\n\nThe following example shows a `DriverStatusListener` implementation: \n\n class MyStatusListener implements DriverStatusListener {\n /** Called when background status is updated, during actions such as location reporting. */\n @Override\n public void updateStatus(\n StatusLevel statusLevel, StatusCode statusCode, String statusMsg, @Nullable Throwable cause) {\n // Existing implementation\n\n if (cause != null && cause instanceof StatusRuntimeException) {\n if (Status.NOT_FOUND.getCode().equals(cause.getStatus().getCode())) {\n // NOT_FOUND gRPC exception thrown by Fleet Engine.\n }\n }\n }\n }\n\n DriverContextBuilder.setDriverStatusListener(new MyStatusListener());\n\nEnable location updates\n-----------------------\n\nOnce you have a `*VehicleReporter` instance, enable location updates as follows: \n\n### Java\n\n DeliveryVehicleReporter reporter = ...;\n\n reporter.enableLocationTracking();\n\n### Kotlin\n\n val reporter = ...\n\n reporter.enableLocationTracking()\n\n### (Optional) Set the update interval\n\nBy default, the Driver SDK sends location updates at 10-second intervals. Each\nlocation update also indicates that the vehicle is online. You can change this\ninterval with\n`reporter.setLocationReportingInterval(long, TimeUnit)`. The minimum supported\nupdate interval is 5 seconds. More frequent updates may result in slower\nrequests and errors."]]