Skip to main content
←API Reference ←com.nianticspatial.nsdk

NSDKSession

↳ extends Closeable

Declaration​

class NSDKSession

Summary​

Creates a new NSDK instance with auth tokens or a configuration file. This is the primary entry point for initializing NSDK functionality. You must call this before using any other NSDK features. Only one [NSDKSession] may be active at a time. Creating a second instance while one is active will throw [IllegalStateException]. Call [close] on the existing session before creating a new one. The session and its feature sessions may be used from any thread. [close] waits for NSDK calls already running on other threads to return; after it, those calls fail or return empty results instead of touching the destroyed native instance.

Throws​

  • IllegalStateException — if native libraries failed to load or a session is already active

Constructors​

Constructor​

constructor(configFilePath: String, logCallback: NsdkLogCallback? = null)

Summary​

Creates a new NSDK instance from a JSON configuration file.
Throws IllegalStateException if initialization fails.


Create it on the main thread. The native creation methods carry @MainThread, but on private
members, so lint does not check callers; NSDK is only tested with the main thread here.

Parameters​

NameTypeSummary
configFilePathString
-
logCallbackNsdkLogCallback?
-

Overload 1​

constructor(config: NsdkConfiguration.Configuration, pathConfig: PathConfig? = null)

Summary​

Creates a new NSDK instance from a programmatic configuration object.
Throws IllegalStateException if initialization fails.


Device metadata is automatically populated from Android platform APIs.


Create it on the main thread. The native creation methods carry @MainThread, but on private
members, so lint does not check callers; NSDK is only tested with the main thread here.

Parameters​

NameTypeSummary
configNsdkConfiguration.Configuration
-
pathConfigPathConfig?
-

Overload 2​

constructor(accessToken: String, useLidar: Boolean = false, pathConfig: PathConfig? = null, logCallback: NsdkLogCallback? = null)

Summary​

Creates a new NSDK instance with an access token.
The token will be forwarded to native for validation and persistence.


Create it on the main thread. The native creation methods carry @MainThread, but on private
members, so lint does not check callers; NSDK is only tested with the main thread here.

Parameters​

NameTypeSummary
accessTokenString
-
useLidarBoolean
-
pathConfigPathConfig?
-
logCallbackNsdkLogCallback?
-

Properties​

NameTypeSummary
dashcamDashcamSession
-
dataSourceNsdkSessionDataSource?
The data source that supplies sensor samples to [update].
Assign a [NsdkSessionDataSource] before calling [update]. Set to null to release it.
depthSessionDepthSession
-
isAuthorizedBoolean
Indicates whether the ARDK session is authorized with valid tokens.
Use this property to check if authentication is complete before making
API calls that require authorization. You can poll this property to wait
for token refresh to complete.
Example usage:
// Wait for authorization before making API calls
while (!ardkSession.isAuthorized) {
delay(1000)
}
// Now safe to make authorized API calls
mappingDeviceMappingSession
-
mapStoreMappingStorageSession
-
meshDownloadMeshDownloaderSession
-
meshingSessionMeshingSession
-
playbackCachePlaybackCacheSession
-
recordingExporterRecordingExporter
-
scanningScanningSession
-
sceneSegmentationSceneSegmentationSession
-
sitesSitesSession
-
vps2Vps2Session
-

Functions​

NameTypeSummary
closevoid
Destroys an NSDK instance and any remaining opened feature sessions
and frees associated resources.
Must be called when the session is no longer needed. Its native resources are not freed
any other way: a session that is garbage collected without [close] leaks them, and a new
[NSDKSession] can then be created alongside it.
Safe to call more than once and from any thread. Waits for NSDK calls running on other
threads to return. Do not call it from the log callback or from inside another NSDK call.
disableTelemetryvoid
Disables telemetry collection for this process.
Clears any buffered telemetry events and stops accepting new ones.
This is a process-wide operation.
getAccessAuthInfoAuthInfo?
Gets access token authentication information.
Returns authentication information containing information about the current access token.
getRefreshAuthInfoAuthInfo?
Gets refresh token authentication information.
Returns authentication information containing information about the current refresh token.
getRequestedDataFormatsInt
Gets the data formats that NSDK requires for processing.
This function returns a bitmask indicating which types of input data
(camera frames, depth, IMU, etc.) NSDK needs for optimal performance.
Use this to configure your data capture pipeline accordingly.
getVersionString
Returns the NSDK version string from the native library.
sendFramevoid
-
setAccessTokenvoid
Set the access token at runtime. Invalid/empty tokens are ignored by native.
setCallbackLogLevelvoid
Sets the log level for callback logs.
This function filters out logs of less severity than the specified level
for the callback logger.
setFileLogLevelvoid
Sets the log level for file logs.
This function filters out logs of less severity than the specified level
for the file logger.
setLogOutputPathvoid
Sets the diagnostic output folder for log.txt, ardk_trace.log, and future VPS debugger files.
No-op if the path is empty or unchanged.
setStdoutLogLevelvoid
Sets the log level for stdout logs.
This function filters out logs of less severity than the specified level
for the stdout logger.
updatevoid
Pulls sensor samples from [dataSource] and submits a frame for native processing.
No-op if [dataSource] is null or not ready.
Call this once per camera frame. Because this is an expensive operation, consider
throttling the calls if you notice degraded app performance.