Package 

Class VoiceContextRegistry


  • 
    public final class VoiceContextRegistry
    
                        

    Registry 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.

    • A VoiceToolContract.ACTION_CONTEXT_CHANGED broadcast is sent so the voice assistant app re-queries the VoiceContextProvider ContentProvider 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."
                )
            )
        }
    }

    The VoiceContextProvider ContentProvider must be declared in your app's AndroidManifest.xml. If you include the VoiceAssistCapabilities library as a dependency, this is handled automatically via manifest merging.

    • Constructor Detail

      • VoiceContextRegistry

        VoiceContextRegistry(Context context)