Configuration
﹟ Create an Application Instance
Customize your app by configuring options before your HotwireActivity
instance is created by the system. We recommend using an Application
instance to place the configuration code.
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Set configuration options
}
}
To ensure this invoked when the app starts, add the name of your Application
instance to AndroidManifest.xml
via the android:name
property on the <application>
node.
p
<application android:name=".MyApplication">
<!-- ... -->
</application>
﹟ Options
Enable debugging in debug builds:
Hotwire.config.debugLoggingEnabled = BuildConfig.DEBUG
Hotwire.config.webViewDebuggingEnabled = BuildConfig.DEBUG
Set the default fragment destination:
Hotwire.defaultFragmentDestination = WebFragment::class
Register fragment destinations:
Hotwire.registerFragmentDestinations(
MyCustomFragment::class
)
Register bridge components, where the first argument is the component name to match in Stimulus:
Hotwire.registerBridgeComponents(
BridgeComponentFactory("my-custom", ::MyCustomComponent)
)
Set the JSON converter used for bridge components:
Hotwire.config.jsonConverter = KotlinXJsonConverter()
Customize the user agent:
Hotwire.config.userAgent = "My Application; ${Hotwire.config.userAgentSubstring()}"