-
public final class VoiceContextRegistryRegistry for contextual information that the voice assistant uses to enrich its system prompt.
External applications use this class to register VoiceContextInfo entries. Descriptive metadata such as the active unit system, the purpose of the host application, or the current work context. These entries are not callable tools; they provide background knowledge that helps the LLM generate more relevant responses.
The host app registers one or more VoiceContextInfo entries via registerContext or registerAllContext.
The registry stores them keyed by VoiceContextInfo.key for deduplication.
The full current context list is pushed via
bulkInsert()to VoiceAssist'sVoiceRegistrationProvider(one row per entry), so the voice assistant app updates its record for this app and refreshes the system prompt.
Inject the registry and register context entries at app startup:
@Singleton class MyAppInitializer @Inject constructor( private val contextRegistry: VoiceContextRegistry ) { fun initialize() { contextRegistry.registerContext( VoiceContextInfo( key = "unit_system", description = "The operator uses metric units." ) ) contextRegistry.registerContext( VoiceContextInfo( key = "app_purpose", description = "This application manages on-board weighing for loading operations." ) ) } }No manual manifest setup is required. The broadcast receiver that keeps registration state in sync at start-up is declared in the library's
AndroidManifest.xmland merged into the host app's manifest automatically.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classVoiceContextRegistry.Companion
-
Constructor Summary
Constructors Constructor Description VoiceContextRegistry(Context context)
-
Method Summary
Modifier and Type Method Description final UnitregisterContext(VoiceContextInfo info, Boolean broadcastIntent)Register a single context entry. final UnitregisterAllContext(Set<VoiceContextInfo> entries, Boolean broadcastIntent)Replace all registered context entries with the given set. final BooleanunregisterContext(String key, Boolean broadcastIntent)Remove a previously registered context entry by its key. final UnitunregisterAllContext()Remove all registered context entries and push the change. final List<VoiceContextInfo>getRegisteredContext()Returns all currently registered context entries. final VoiceContextInfogetContext(String key)Returns a specific context entry by key, or nullif not found.-
-
Constructor Detail
-
VoiceContextRegistry
VoiceContextRegistry(Context context)
-
-
Method Detail
-
registerContext
final Unit registerContext(VoiceContextInfo info, Boolean broadcastIntent)
Register a single context entry. If an entry with the same VoiceContextInfo.key already exists, it is replaced.
- Parameters:
info- The context entry to register.broadcastIntent- Whether to push the updated context to VoiceAssist immediately.
-
registerAllContext
final Unit registerAllContext(Set<VoiceContextInfo> entries, Boolean broadcastIntent)
Replace all registered context entries with the given set.
- Parameters:
entries- The full set of context entries to register.broadcastIntent- Whether to push the change to VoiceAssist immediately.
-
unregisterContext
final Boolean unregisterContext(String key, Boolean broadcastIntent)
Remove a previously registered context entry by its key.
- Parameters:
key- The key of the context entry to remove.broadcastIntent- Whether to push the change to VoiceAssist immediately.
-
unregisterAllContext
final Unit unregisterAllContext()
Remove all registered context entries and push the change.
-
getRegisteredContext
final List<VoiceContextInfo> getRegisteredContext()
Returns all currently registered context entries.
-
getContext
final VoiceContextInfo getContext(String key)
Returns a specific context entry by key, or
nullif not found.
-
-
-
-