@@ -78,23 +78,33 @@ This library uses a custom broadcast receiver to handle the manual orientation c
7878autorotation feature and the system prompts the user to rotate the device, the library will listen to the broadcast
7979sent by the MainActivity and update the interface orientation accordingly.
8080
81- To allow the library to listen to the broadcast, you need to override the ` onConfigurationChanged ` method in your
82- MainActivity file, as shown below:
81+ To allow the library to listen to the broadcast, you need to override the ` onConfigurationChanged ` method in MainActivity.kt as shown below:
8382
8483``` kotlin
85- override fun onConfigurationChanged (newConfig : Configuration ) {
86- super .onConfigurationChanged(newConfig)
84+ // ...
8785
88- val orientationDirectorCustomAction =
89- " ${packageName} .${ConfigurationChangedBroadcastReceiver .CUSTOM_INTENT_ACTION } "
86+ import android.content.Intent
87+ import android.content.res.Configuration
88+ import com.orientationdirector.implementation.ConfigurationChangedBroadcastReceiver
9089
91- val intent =
92- Intent (orientationDirectorCustomAction).apply {
93- putExtra(" newConfig" , newConfig)
94- setPackage(packageName)
95- }
90+ class MainActivity : ReactActivity () {
9691
97- this .sendBroadcast(intent)
92+ // ...
93+
94+ override fun onConfigurationChanged (newConfig : Configuration ) {
95+ super .onConfigurationChanged(newConfig)
96+
97+ val orientationDirectorCustomAction =
98+ " ${packageName} .${ConfigurationChangedBroadcastReceiver .CUSTOM_INTENT_ACTION } "
99+
100+ val intent =
101+ Intent (orientationDirectorCustomAction).apply {
102+ putExtra(" newConfig" , newConfig)
103+ setPackage(packageName)
104+ }
105+
106+ this .sendBroadcast(intent)
107+ }
98108}
99109```
100110
0 commit comments