Fix: Handle exception if Context.registerReceiver throws #1747
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Fix: Handle exception if Context.registerReceiver throws
💡 Motivation and Context
Caused by: java.lang.SecurityException:
at android.os.Parcel.createExceptionOrNull (Parcel.java:2385)
at android.os.Parcel.createException (Parcel.java:2369)
at android.os.Parcel.readException (Parcel.java:2352)
at android.os.Parcel.readException (Parcel.java:2294)
at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature (IActivityManager.java:6381)
at android.app.ContextImpl.registerReceiverInternal (ContextImpl.java:1696)
at android.app.ContextImpl.registerReceiver (ContextImpl.java:1650)
at android.app.ContextImpl.registerReceiver (ContextImpl.java:1638)
at android.content.ContextWrapper.registerReceiver (ContextWrapper.java:686)
at io.sentry.android.core.SystemEventsBreadcrumbsIntegration.register (SystemEventsBreadcrumbsIntegration.java:98)
at io.sentry.Sentry.init (Sentry.java:181)
at io.sentry.Sentry.init (Sentry.java:110)
at io.sentry.android.core.SentryAndroid.init (SentryAndroid.java:59)
at io.sentry.android.core.SentryAndroid.init (SentryAndroid.java:44)
at com.png.sportsbook.app.App.onCreate (App.kt:73)
at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7535)
at android.app.ActivityThread.access$1500 (ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2158)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8595)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
💚 How did you test it?
unit test
📝 Checklist
🔮 Next steps