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.

    • The full current context list is pushed via bulkInsert() to VoiceAssist's VoiceRegistrationProvider (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.xml and merged into the host app's manifest automatically.

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