Make the first API call
Describes the order of NaviHelper API calls and example scenarios that can be implemented with the API.
API call order
1. Initialize SDK
When starting the NaviHelper SDK, call the initialize API to initialize the NaviHelper SDK.
- Kotlin
- Java
val naviHelper: NaviHelper = NaviHelper(context)
naviHelper.initialize()
NaviHelper naviHelper = new NaviHelper(context);
naviHelper.initialize();
2. Add eventListener
Before registering the NaviHelper app, call the addEventListener API to register the NaviHelper event callbacks.
- Kotlin
- Java
naviHelper.addListener(listener: ai.pleos.playground.navi.helper.listener.NaviHelperEventListener)
naviHelper.addListener(new ai.pleos.playground.navi.helper.listener.NaviHelperEventListener());
3. Remove eventListener
Before exiting the Navigation app, release the registered event callbacks. To release event callbacks, call the removeEventListener API.
- Kotlin
- Java
naviHelper.removeListener(listener: ai.pleos.playground.navi.helper.listener.NaviHelperEventListener)
naviHelper.removeListener(new ai.pleos.playground.navi.helper.listener.NaviHelperEventListener());
4. Release SDK
Call the release API to free the resources of the NaviHelper SDK.
- Kotlin
- Java
naviHelper.release()
naviHelper.release();
Example API usage scenarios
- 1. Set, confirm and cancel destination
- 2. Set and delete waypoints
- 3. Change route options
- 4. Re-route
- 5. Confirm navigation information
- 6. Check charger operator information
1. Set, confirm and cancel destination
- Kotlin
- Java
// Set destination
naviHelper.requestRoute(
RouteInfo(
latitude = 37.48544722,
longitude = 127.03636666,
poiId = "36khp37hh8gqcm5nqhe5",
poiName = "42dot",
poiSubId = "0",
address = "Seoul, Gangnam-gu, NamBusunhwan-ro 2621"
)
)
// Confirm destination
naviHelper.getDestinationInfo()
// Receive data with onDestinationInfo callback
override fun onDestinationInfo(destinationInfo: DestinationInfo) {
Log.d(logTag, "onDestinationInfo $destinationInfo")
}
// Cancel destination
naviHelper.cancelRoute()
// Set destination
naviHelper.requestRoute(new RouteInfo(
127.03636666,
37.48544722,
"42dot",
"36khp37hh8gqcm5nqhe5",
"Seoul, Gangnam-gu, NamBusunhwan-ro 2621",
"0",
RouteOption.RECOMMENDED
));
// Confirm destination
naviHelper.getDestinationInfo();
// Receive data with onDestinationInfo callback
@Override
public void onDestinationInfo(DestinationInfo destinationInfo) {
Log.d(logTag, "onDestinationInfo = " + destinationInfo);
}
// Cancel destination
naviHelper.cancelRoute();
2. Set and delete waypoints
- Kotlin
- Java
// Set destination
naviHelper.requestRoute(
RouteInfo(
latitude = 37.48544722,
longitude = 127.03636666,
poiId = "36khp37hh8gqcm5nqhe5",
poiName = "42dot",
poiSubId = "0",
address = "Seoul, Gangnam-gu, NamBusunhwan-ro 2621",
)
)
// Add waypoint
naviHelper.addWaypoint(
RequestWaypointInfo(
latitude = 37.41275833,
longitude = 127.09481944,
waypointIndex = WaypointIndex.FIRST,
poiId = "36khp2hdj2cfcm5nqhe3",
poiName = "Software Dream Center",
poiSubId = "0",
address = "6, Changup-ro 40beon-gil, Sujeong-gu, Seongnam-si, Gyeonggi-do",
)
)
// Receive data with onWaypointInfo callback
override fun onWaypointInfo(waypointInfo: List<WaypointInfo>) {
Log.d(logTag, "onWaypointInfo $waypointInfo")
}
// Delete waypoint
naviHelper.removeWaypoint(WaypointIndex.FIRST)
// Cancel destination
naviHelper.cancelRoute()
// Set destination
naviHelper.requestRoute(new RouteInfo(
127.03636666,
37.48544722,
"42dot",
"36khp37hh8gqcm5nqhe5",
"Seoul, Gangnam-gu, NamBusunhwan-ro 2621",
"0",
RouteOption.RECOMMENDED
));
// Add waypoint
naviHelper.addWaypoint(new RequestWaypointInfo(
127.09481944,
37.41275833,
"Software Dream Center",
WaypointIndex.FIRST,
"36khp2hdj2cfcm5nqhe3",
"6, Changup-ro 40beon-gil, Sujeong-gu, Seongnam-si, Gyeonggi-do",
"0"
));
// Receive data with onWaypointInfo callback
@Override
public void onWayPointInfo(List<WaypointInfo> list) {
Log.d(logTag, "onWayPointInfo = " + list);
}
// Delete waypoint
naviHelper.removeWaypoint(WaypointIndex.FIRST);
// Cancel destination
naviHelper.cancelRoute();
3. Change route options
- Kotlin
- Java
// Set destination
naviHelper.requestRoute(
RouteInfo(
latitude = 37.48544722,
longitude = 127.03636666,
poiId = "36khp37hh8gqcm5nqhe5",
poiName = "42dot",
poiSubId = "0",
address = "Seoul, Gangnam-gu, NamBusunhwan-ro 2621",
)
)
// Change route option: switch to highway-priority
naviHelper.changeRouteOption(RouteOption.HIGHWAY)
// Receive changed data with onRouteOptionChanged callback
override fun onRouteOptionChanged(routeOption: RouteOption) {
Log.d(logTag, "onRouteOptionChanged $routeOption")
}
// Cancel destination
naviHelper.cancelRoute()
// Set destination
naviHelper.requestRoute(new RouteInfo(
127.03636666,
37.48544722,
"42dot",
"36khp37hh8gqcm5nqhe5",
"Seoul, Gangnam-gu, NamBusunhwan-ro 2621",
"0",
RouteOption.RECOMMENDED
));
// Change route option: switch to highway-priority
naviHelper.changeRouteOption(RouteOption.HIGHWAY);
// Receive changed data with onRouteOptionChanged callback
@Override
public void onRouteOptionChanged(@NonNull RouteOption routeOption) {
Log.d(logTag, "onRouteOptionChanged = " + routeOption);
}
// Cancel destination
naviHelper.cancelRoute();
4. Re-route
- Kotlin
- Java
// Set destination
naviHelper.requestRoute(
RouteInfo(
latitude = 37.48544722,
longitude = 127.03636666,
poiId = "36khp37hh8gqcm5nqhe5",
poiName = "42dot",
poiSubId = "0",
address = "Seoul, Gangnam-gu, NamBusunhwan-ro 2621"
)
)
// Request re-route
naviHelper.requestReRoute()
// Cancel destination
naviHelper.cancelRoute()
// Set destination
naviHelper.requestRoute(new RouteInfo(
127.03636666,
37.48544722,
"42dot",
"36khp37hh8gqcm5nqhe5",
"Seoul, Gangnam-gu, NamBusunhwan-ro 2621",
"0",
RouteOption.RECOMMENDED
));
// Request re-route
naviHelper.requestReRoute()
// Cancel destination
naviHelper.cancelRoute()
5. Confirm navigation information
- Kotlin
- Java
// Set destination
naviHelper.requestRoute(
RouteInfo(
latitude = 37.48544722,
longitude = 127.03636666,
poiId = "36khp37hh8gqcm5nqhe5",
poiName = "42dot",
poiSubId = "0",
address = "Seoul, Gangnam-gu, NamBusunhwan-ro 2621"
)
)
// Check bookmark information
naviHelper.getBookmarkInfo()
// Receive data with onBookmarkInfo callback
override fun onBookmarkInfo(bookmarkInfo: List<BookmarkInfo>) {
Log.d(logTag, "onBookmarkInfo $bookmarkInfo")
}
// Check current location information
naviHelper.getCurrentLocationInfo()
// Receive data with onCurrentLocationInfo callback
override fun onCurrentLocationInfo(currentLocationInfo: CurrentLocationInfo) {
Log.d(logTag, "onCurrentLocationInfo $currentLocationInfo")
}
// Check recent destination information
naviHelper.getRouteStateInfo()
// Receive data with onRouteStateInfo callback
override fun onRouteStateInfo(routeStateInfo: RouteStateInfo) {
Log.d(logTag, "onRouteStateInfo $routeStateInfo")
}
// Check recent destination information
naviHelper.getRecentDestinationInfo()
// Receive data with onRecentDestinationInfo callback
override fun onRecentDestinationInfo(recentDestinationInfo: RecentDestinationInfo) {
Log.d(logTag, "onRecentDestinationInfo $recentDestinationInfo")
}
// Cancel destination
naviHelper.cancelRoute()
// Set destination
naviHelper.requestRoute(new RouteInfo(
127.03636666,
37.48544722,
"42dot",
"36khp37hh8gqcm5nqhe5",
"Seoul, Gangnam-gu, NamBusunhwan-ro 2621",
"0",
RouteOption.RECOMMENDED
));
// Check bookmark information
naviHelper.getBookmarkInfo();
// Receive data with onBookmarkInfo callback
@Override
public void onBookmarkInfo(List<BookmarkInfo> list) {
Log.d(logTag, "onBookmarkInfo = " + list);
}
// Check current location information
naviHelper.getCurrentLocationInfo();
// Receive data with onCurrentLocationInfo callback
@Override
public void onCurrentLocationInfo(CurrentLocationInfo currentLocationInfo) {
Log.d(logTag, "onCurrentLocationInfo = " + currentLocationInfo);
}
// Check driving information
naviHelper.getRouteStateInfo();
@Override
public void onRouteStateInfo(RouteStateInfo routeStateInfo) {
Log.d(logTag, "onRouteStateInfo = " + routeStateInfo);
}
// Check recent destination information
naviHelper.getRecentDestinationInfo();
// Receive data with onRecentDestinationInfo callback
@Override
public void onRecentDestinationInfo(List<RecentDestinationInfo> list) {
Log.d(logTag, "onRecentDestinationInfo = " + list);
}
// Cancel destination
naviHelper.cancelRoute();
6. Check charger operator information
- Kotlin
- Java
naviHelper.getChargerOperatorInfo()
// Receive data with onChargerOperatorInfo callback
override fun onChargerOperatorInfo(chargerOperatorList: List<ChargerOperator>) {
Log.d(logTag, "onChargerOperatorInfo chargerOperatorList")
}
naviHelper.getChargerOperatorInfo();
// Receive data with onChargerOperatorInfo callback
@Override
public void onChargerOperatorInfo(List<ChargerOperator> list) {
Log.d(logTag, "onChargerOperatorInfo = " + list);
}