-
Notifications
You must be signed in to change notification settings - Fork 292
Open
Description
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch react-native-orientation-locker@1.5.0 for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-orientation-locker/android/src/main/java/org/wonday/orientation/OrientationModule.java b/node_modules/react-native-orientation-locker/android/src/main/java/org/wonday/orientation/OrientationModule.java
index 4a44ff6..7842baf 100644
--- a/node_modules/react-native-orientation-locker/android/src/main/java/org/wonday/orientation/OrientationModule.java
+++ b/node_modules/react-native-orientation-locker/android/src/main/java/org/wonday/orientation/OrientationModule.java
@@ -16,6 +16,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.hardware.SensorManager;
+import android.os.Build;
import android.view.Display;
import android.view.OrientationEventListener;
import android.view.Surface;
@@ -59,7 +60,6 @@ public class OrientationModule extends ReactContextBaseJavaModule implements Ori
String deviceOrientationValue = lastDeviceOrientationValue;
-
if (orientation == -1) {
deviceOrientationValue = "UNKNOWN";
} else if (orientation > 355 || orientation < 5) {
@@ -349,11 +349,20 @@ public class OrientationModule extends ReactContextBaseJavaModule implements Ori
return constants;
}
+ // Add this method to handle receiver registration with Android 14 compatibility
+ private void compatRegisterReceiver(Context context, BroadcastReceiver receiver, IntentFilter filter, boolean exported) {
+ if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) {
+ context.registerReceiver(receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED);
+ } else {
+ context.registerReceiver(receiver, filter);
+ }
+ }
+
@Override
public void start() {
FLog.i(ReactConstants.TAG, "orientation detect enabled.");
mOrientationListener.enable();
- ctx.registerReceiver(mReceiver, new IntentFilter("onConfigurationChanged"));
+ compatRegisterReceiver(ctx, mReceiver, new IntentFilter("onConfigurationChanged"), false);
}
@OverrideThis issue body was partially generated by patch-package.
Metadata
Metadata
Assignees
Labels
No labels