1package com.navigine.examples
3import com.navigine.idl.java.*
6 * NavigineSDK usage example for Kotlin
7 * Demonstrates SDK initialization and access to various managers
9class NavigineSdkExample {
11 private var sdk: NavigineSdk? = null
12 private var locationManager: LocationManager? = null
13 private var navigationManager: NavigationManager? = null
14 private var zoneManager: ZoneManager? = null
15 private var routeManager: RouteManager? = null
16 private var asyncRouteManager: AsyncRouteManager? = null
17 private var notificationManager: NotificationManager? = null
18 private var measurementManager: MeasurementManager? = null
19 private var locationListManager: LocationListManager? = null
20 private var storageManager: StorageManager? = null
27 * SDK initialization and basic parameter setup
29 private fun initializeSdk() {
31 // [kotlin_NavigineSdk_getInstance]
33 sdk = NavigineSdk.getInstance()
34 // [kotlin_NavigineSdk_getInstance]
36 // [kotlin_NavigineSdk_getVersion]
38 println("Navigine SDK Version: ${NavigineSdk.getVersion()}")
39 // [kotlin_NavigineSdk_getVersion]
41 // [kotlin_NavigineSdk_getDeviceId]
43 println("Device ID: ${NavigineSdk.getDeviceId()}")
44 // [kotlin_NavigineSdk_getDeviceId]
46 // [kotlin_NavigineSdk_getRelativeTime]
48 println("Relative Time: ${NavigineSdk.getRelativeTime()}")
49 // [kotlin_NavigineSdk_getRelativeTime]
51 // [kotlin_NavigineSdk_setUserHash]
52 // Set user hash (authorization token)
53 sdk?.setUserHash("XXXX-XXXX-XXXX-XXXX")
54 // [kotlin_NavigineSdk_setUserHash]
56 // [kotlin_NavigineSdk_setServer]
57 // Set server URL (optional)
58 sdk?.setServer("https://custom.navigine.com")
59 // [kotlin_NavigineSdk_setServer]
61 // Initialize managers
64 } catch (e: Exception) {
65 System.err.println("SDK initialization error: ${e.message}")
70 * Initialize all SDK managers
72 private fun initializeManagers() {
73 sdk?.let { sdkInstance ->
74 // [kotlin_NavigineSdk_getLocationManager]
75 // Get LocationManager for working with locations
76 locationManager = sdkInstance.locationManager
77 locationManager?.let {
78 println("LocationManager successfully initialized")
80 // [kotlin_NavigineSdk_getLocationManager]
82 // [kotlin_NavigineSdk_getNavigationManager]
83 // Get NavigationManager for navigation
84 locationManager?.let { locationManager ->
85 navigationManager = sdkInstance.getNavigationManager(locationManager)
86 navigationManager?.let {
87 println("NavigationManager successfully initialized")
90 // [kotlin_NavigineSdk_getNavigationManager]
92 // [kotlin_NavigineSdk_getZoneManager]
93 // Get ZoneManager for working with zones
94 navigationManager?.let { navigationManager ->
95 zoneManager = sdkInstance.getZoneManager(navigationManager)
97 println("ZoneManager successfully initialized")
100 // [kotlin_NavigineSdk_getZoneManager]
102 // [kotlin_NavigineSdk_getRouteManager]
103 // Get RouteManager for building routes
104 locationManager?.let { locationManager ->
105 navigationManager?.let { navigationManager ->
106 routeManager = sdkInstance.getRouteManager(locationManager, navigationManager)
108 println("RouteManager successfully initialized")
112 // [kotlin_NavigineSdk_getRouteManager]
114 // [kotlin_NavigineSdk_getAsyncRouteManager]
115 // Get AsyncRouteManager for async route operations
116 locationManager?.let { locationManager ->
117 navigationManager?.let { navigationManager ->
118 asyncRouteManager = sdkInstance.getAsyncRouteManager(locationManager, navigationManager)
119 asyncRouteManager?.let {
120 println("AsyncRouteManager successfully initialized")
124 // [kotlin_NavigineSdk_getAsyncRouteManager]
126 // [kotlin_NavigineSdk_getNotificationManager]
127 // Get NotificationManager for notifications
128 locationManager?.let { locationManager ->
129 notificationManager = sdkInstance.getNotificationManager(locationManager)
130 notificationManager?.let {
131 println("NotificationManager successfully initialized")
134 // [kotlin_NavigineSdk_getNotificationManager]
136 // [kotlin_NavigineSdk_getMeasurementManager]
137 // Get MeasurementManager for measurements
138 locationManager?.let { locationManager ->
139 measurementManager = sdkInstance.getMeasurementManager(locationManager)
140 measurementManager?.let {
141 println("MeasurementManager successfully initialized")
144 // [kotlin_NavigineSdk_getMeasurementManager]
146 // [kotlin_NavigineSdk_getLocationListManager]
147 // Get LocationListManager for location list operations
148 locationListManager = sdkInstance.locationListManager
149 locationListManager?.let {
150 println("LocationListManager successfully initialized")
152 // [kotlin_NavigineSdk_getLocationListManager]
154 // [kotlin_NavigineSdk_getStorageManager]
155 // Get StorageManager for working with storages
156 storageManager = sdkInstance.storageManager
157 storageManager?.let {
158 println("StorageManager successfully initialized")
160 // [kotlin_NavigineSdk_getStorageManager]
165 * Get information about current SDK state
168 println("=== Navigine SDK Information ===")
169 println("SDK Version: ${NavigineSdk.getVersion()}")
170 println("Device ID: ${NavigineSdk.getDeviceId()}")
171 println("Relative Time: ${NavigineSdk.getRelativeTime()}")
172 println("LocationManager: ${if (locationManager != null) "available" else "unavailable"}")
173 println("NavigationManager: ${if (navigationManager != null) "available" else "unavailable"}")
174 println("ZoneManager: ${if (zoneManager != null) "available" else "unavailable"}")
175 println("RouteManager: ${if (routeManager != null) "available" else "unavailable"}")
176 println("AsyncRouteManager: ${if (asyncRouteManager != null) "available" else "unavailable"}")
177 println("NotificationManager: ${if (notificationManager != null) "available" else "unavailable"}")
178 println("MeasurementManager: ${if (measurementManager != null) "available" else "unavailable"}")
179 println("LocationListManager: ${if (locationListManager != null) "available" else "unavailable"}")
180 println("StorageManager: ${if (storageManager != null) "available" else "unavailable"}")
184 * Demonstrate usage of all managers
186 fun demonstrateManagersUsage() {
187 println("=== Manager Usage Demonstration ===")
189 // LocationManager usage example
190 locationManager?.let {
191 println("LocationManager ready for location operations")
192 // Add code here for loading locations, working with them, etc.
195 // NavigationManager usage example
196 navigationManager?.let {
197 println("NavigationManager ready for positioning")
198 // Add code here for getting position, setting up listeners, etc.
201 // ZoneManager usage example
203 println("ZoneManager ready for zone operations")
204 // Add code here for setting up zones, handling enter/exit events, etc.
207 // RouteManager usage example
209 println("RouteManager ready for route building")
210 // Add code here for building routes, setting destination points, etc.
213 // AsyncRouteManager usage example
214 asyncRouteManager?.let {
215 println("AsyncRouteManager ready for async route operations")
216 // Add code here for creating routing sessions, etc.
219 // NotificationManager usage example
220 notificationManager?.let {
221 println("NotificationManager ready for notifications")
222 // Add code here for setting up beacon notifications, etc.
225 // MeasurementManager usage example
226 measurementManager?.let {
227 println("MeasurementManager ready for measurements")
228 // Add code here for managing measurement generators, etc.
231 // LocationListManager usage example
232 locationListManager?.let {
233 println("LocationListManager ready for location list operations")
234 // Add code here for getting available locations list, etc.
237 // StorageManager usage example
238 storageManager?.let {
239 println("StorageManager ready for storage operations")
240 // Add code here for creating storages, managing data, etc.
245 * Demonstrate Kotlin features usage
247 fun demonstrateKotlinFeatures() {
248 println("=== Kotlin Features Demonstration ===")
250 // Using let for safe calls
251 sdk?.let { sdkInstance ->
252 sdkInstance.setUserHash("YYYY-YYYY-YYYY-YYYY")
253 println("User hash updated")
256 // Using run for code block execution
259 "version" to NavigineSdk.getVersion(),
260 "deviceId" to NavigineSdk.getDeviceId(),
261 "relativeTime" to NavigineSdk.getRelativeTime()
264 println("SDK Information: $sdkInfo")
266 // Using with for object operations
267 with(locationManager) {
269 println("LocationManager available for operations")
270 // Call LocationManager methods here
274 // Using apply for object configuration
276 setUserHash("ZZZZ-ZZZZ-ZZZZ-ZZZZ")
277 setServer("https://custom.navigine.com")
279 println("SDK settings updated")
283 * Main function for demonstration
287 fun main(args: Array<String>) {
288 val example = NavigineSdkExample()
289 example.printSdkInfo()
290 example.demonstrateManagersUsage()
291 example.demonstrateKotlinFeatures()