Skip to content

Commit

Permalink
Android 14 support (#7801)
Browse files Browse the repository at this point in the history
From react native [pr](facebook/react-native#38256)
> Summary:
> Add RECEIVER_EXPORTED/RECEIVER_NOT_EXPORTED flag support to DevSupportManagerBase for Android 14 change. See
> https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported for details.
> 
> Without this fix, app crashes during launch because of :
> SecurityException: {package name here}: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
  • Loading branch information
axinvd committed Nov 6, 2023
1 parent 570aae5 commit 58edd09
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.IntentFilter;
import android.view.KeyEvent;
import android.widget.EditText;
import android.os.Build;

import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.reactnativenavigation.utils.UiUtils;
Expand Down Expand Up @@ -49,7 +50,11 @@ public void removeReloadListener(ReloadListener listener) {
}

public void onActivityResumed(Activity activity) {
activity.registerReceiver(reloadReceiver, new IntentFilter(RELOAD_BROADCAST));
if (Build.VERSION.SDK_INT >= 34 && activity.getApplicationInfo().targetSdkVersion >= 34) {
activity.registerReceiver(reloadReceiver, new IntentFilter(RELOAD_BROADCAST), Context.RECEIVER_EXPORTED);
} else {
activity.registerReceiver(reloadReceiver, new IntentFilter(RELOAD_BROADCAST));
}
}

public void onActivityPaused(Activity activity) {
Expand Down

0 comments on commit 58edd09

Please sign in to comment.