Configure Android for react-native-orientation-locker
masterAndroid requires updates to three different files to handle orientation changes correctly.
1. Update AndroidManifest.xml
Add android:configChanges="keyboard|keyboardHidden|orientation|screenSize" to your activity:
<activity
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">2. Update MainActivity.java
Implement the onConfigurationChanged method to broadcast orientation changes:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Intent intent = new Intent("onConfigurationChanged");
intent.putExtra("newConfig", newConfig);
this.sendBroadcast(intent);
}3. Update MainApplication.java
Register the orientation activity lifecycle callbacks in onCreate:
@Override
public void onCreate() {
super.onCreate();
registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());
}@Override
public void onCreate() {
registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());
}