ก่อนใช้ Driver SDK คุณต้องเริ่มต้น Navigation SDK และ Driver SDK ก่อนโดยทำตามขั้นตอนต่อไปนี้
- รับออบเจ็กต์ - Navigatorจาก- NavigationApi- Java- NavigationApi.getNavigator( this, // Activity new NavigationApi.NavigatorListener() { @Override public void onNavigatorReady(Navigator navigator) { // Keep a reference to the Navigator (used to configure and start nav) this.navigator = navigator; } } );- Kotlin- NavigationApi.getNavigator( this, // Activity object : NavigatorListener() { override fun onNavigatorReady(navigator: Navigator) { // Keep a reference to the Navigator (used to configure and start nav) this@myActivity.navigator = navigator } }, )
- สร้างออบเจ็กต์ - DriverContextโดยป้อนข้อมูลในช่องที่ต้องกรอก หากต้องการ เริ่มต้นออบเจ็กต์- DriverContextคุณต้องป้อนรหัสโปรเจ็กต์ ของโปรเจ็กต์ Google Cloud เป็น- providerIdดูข้อมูล เกี่ยวกับการตั้งค่าโปรเจ็กต์ Google Cloud ได้ที่ สร้างโปรเจ็กต์ Fleet Engine- Java- DriverContext driverContext = DriverContext.builder(application) .setProviderId(providerId) .setVehicleId(vehicleId) .setAuthTokenFactory(authTokenFactory) .setNavigator(navigator) .setRoadSnappedLocationProvider( NavigationApi.getRoadSnappedLocationProvider(application)) .build();- Kotlin- val driverContext = DriverContext.builder(application) .setProviderId(providerId) .setVehicleId(vehicleId) .setAuthTokenFactory(authTokenFactory) .setNavigator(navigator) .setRoadSnappedLocationProvider(NavigationApi.getRoadSnappedLocationProvider(application)) .build()
- ใช้ออบเจ็กต์ - DriverContextเพื่อเริ่มต้น- *DriverApi- DeliveryDriverApi driverApi = DeliveryDriverApi.createInstance(driverContext);
- รับ - DeliveryVehicleReporterจากออบเจ็กต์ API (- DeliveryVehicleReporterขยาย- NavigationVehicleReporter)- DeliveryVehicleReporter vehicleReporter = driverApi.getDeliveryVehicleReporter();
หมายเหตุเกี่ยวกับ SSL/TLS
ภายใน การติดตั้งใช้งาน Driver SDK จะใช้ SSL/TLS เพื่อสื่อสารกับบริการ Fleet Engine อย่างปลอดภัย API ของ Android
เวอร์ชัน 23 หรือ
ก่อนหน้าอาจต้องใช้แพตช์ SecurityProvider เพื่อสื่อสารกับเซิร์ฟเวอร์ ดูข้อมูลเพิ่มเติมเกี่ยวกับการทำงานกับ SSL ใน Android ได้ที่
ผู้ให้บริการ GMS ด้านความปลอดภัย
บทความนี้ยังมีตัวอย่างโค้ดสำหรับการแก้ไขผู้ให้บริการด้านความปลอดภัยด้วย