Skip to content

Commit

Permalink
Fix issue 954: Crash app when answering PN call in Kill/bacground mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tatthangcntt committed Aug 12, 2024
1 parent 01654c8 commit 5df8a01
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ android {
dependencies {
implementation("com.facebook.react:react-android")
implementation(jscFlavor)
// for fix issue: java.lang.SecurityException: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED
//https://medium.com/@siddhantshelake/fixing-broadcastreceiver-crashes-and-metro-server-issues-in-android-14-3b7d05939a43
implementation 'org.jetbrains:annotations:16.0.2'

// react-native-notfication
implementation platform("com.google.firebase:firebase-bom:32.1.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.brekeke.phonedev;

import android.annotation.SuppressLint;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import java.util.List;
import org.jetbrains.annotations.Nullable;

public class MainApplication extends Application implements ReactApplication {

Expand Down Expand Up @@ -51,4 +58,15 @@ public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}

@SuppressLint("WrongConstant")
@Override
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) {
// https://medium.com/@siddhantshelake/fixing-broadcastreceiver-crashes-and-metro-server-issues-in-android-14-3b7d05939a43
if (Build.VERSION.SDK_INT >= 34 && getApplicationInfo().targetSdkVersion >= 34) {
return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
} else {
return super.registerReceiver(receiver, filter);
}
}
}

0 comments on commit 5df8a01

Please sign in to comment.