getOrCreateStateHolder
Returns the existing state holder, or creates and registers a new one.
This method should be used by the app's Hilt module instead of creating a new AndroidAutoStateHolder + calling initialize. This ensures that if Android Auto launched before the phone app and auto-created a holder, the same instance is reused throughout the app.
Usage in Hilt Module
@Provides
@Singleton
fun provideAndroidAutoStateHolder(): AndroidAutoStateHolder {
return AndroidAutoSurfaceManager.getOrCreateStateHolder()
}Content copied to clipboard
Return
The singleton AndroidAutoStateHolder instance