MultiSetLocalizationActivity
Overview
The MultiSetLocalizationActivity is a unified AR localization activity that supports both single-frame and multi-frame localization modes. The mode is selected at launch time via an intent extra.
Description
This is the unified AR localization activity that handles both single-frame and multi-frame localization modes in a single implementation.
Single-frame mode is ideal for:
Quick localization with low latency
Environments with distinct visual features
Limited network bandwidth scenarios
Multi-frame mode is ideal for:
Higher accuracy requirements
Environments with repetitive or sparse visual features
When the user can move the device slightly during capture
The activity handles:
AR session management using ARCore and Sceneform
Single-frame and multi-frame capture and processing
Localization animation with visual feedback
Localization API requests
Pose calculation and gizmo positioning
3D mesh visualization with radial reveal animation
Background localization
GPS hint integration
Launching the Activity
The localization mode is passed via intent extra:
Intent Extras
EXTRA_LOCALIZATION_MODE
String
The localization mode name: "SINGLE_FRAME" or "MULTI_FRAME"
Key Features
Localization Animation
Both modes display an animated phone icon with visual feedback during capture, guiding users to move their device for better coverage.
Auto-Localization
When LocalizationConfig.autoLocalize is enabled, localization starts automatically after the AR session is ready.
Background Localization
When LocalizationConfig.backgroundLocalization is enabled, the activity periodically sends localization requests to refine positioning.
Relocalization
When LocalizationConfig.relocalization is enabled, automatic relocalization is triggered when AR tracking state becomes PAUSED or STOPPED.
GPS Hint
When LocalizationConfig.enableGeoHint is enabled, GPS coordinates are captured and sent as a hint to improve localization accuracy for large-scale maps.
Localization Hints
Before sending a query, the activity reads optional localization hints from LocalizationConfig to narrow the search space:
hintMapCodes: restricts a mapSet query to a subset of maps (ignored for single-map localization).hintPosition("x,y,z") andhintFloorHeight("floor,ceiling"): bias the search around a known area.hintRadiusanduse2DFiltering: spatial filters applied only when a geo hint orhintPositionis present.
See LocalizationConfig → Localization Hints for the full reference.
Mesh Visualization
When LocalizationConfig.enableMeshVisualization is enabled, a 3D mesh overlay with radial reveal animation is rendered after successful localization.
Multi-Frame Capture
In multi-frame mode, captures multiple frames (configurable via LocalizationConfig.numberOfFrames) with intervals between captures (configurable via LocalizationConfig.frameCaptureIntervalMs). Each frame includes:
Image data (JPEG compressed)
Camera position (X, Y, Z)
Camera rotation (quaternion)
Session Wiring
The activity does not implement a capture loop of its own. It builds an ArFrameSource, creates a LocalizationSession from the SDK, applies LocalizationConfig to it, and attaches callbacks. The SDK owns scheduling, retry, background re-localization and confidence gating.
Starting capture
Capture is deferred until ARCore actually reports TRACKING. Starting before then fails with "Failed to capture frame". The activity sets a pendingAutoStart flag and calls session.start() from its scene update once the camera is tracking.
The Localize button
Calls session.start() directly, since the user only sees the button once the scene is live.
The Reset button
Returns the scene to its initial state:
Tracking loss
When ARCore drops out of TRACKING, the activity calls session.notifyTrackingInterrupted() so the pose consistency gate stops trusting a reference the tracker no longer backs. If relocalization is enabled it then restarts the session.
State Management
isSessionConfigured
Boolean
Whether the ARCore session has been configured
sessionStarted
Boolean
Whether capture is currently running
pendingAutoStart
Boolean
Auto-localization is waiting for ARCore to reach TRACKING
lastTrackingState
TrackingState
Previous AR tracking state
localizationMode
LocalizationMode
Mode selected via the launch intent
Capture state such as whether a query is in flight, whether this is the first localization, and the frames captured for a multi-frame query is owned by LocalizationSession inside the SDK and is not exposed to the activity.
Configuration
The activity reads configuration from LocalizationConfig:
Usage Examples
Single-Frame Localization
Multi-Frame Localization
Related
Last updated
Was this helpful?

