fix: reset package name in intent on open link error - #1320
Conversation
ibrahim-iqbal
left a comment
There was a problem hiding this comment.
Good, focused fix. Clearing the package binding with intent.setPackage(null) on the retry drops the reference to the uninstalled browser and hands the choice back to the system, which is exactly what the fallback wants to do.
One tiny follow-up (non-blocking, edge case): the retry startActivity inside the outer catch isn't wrapped in another try/catch, so on a device with no browser installed at all it would throw ActivityNotFoundException and crash. That's the same behaviour that existed before this PR — the fix here still shrinks the crash surface for the common "uninstalled preferred browser" case, which is the reported bug — but if you want to fully harden it you could catch the retry too, or use resolveActivity before calling startActivity. Happy to leave that for a follow-up.
Both call sites (AppUriHandler and Context.openURL) get the same one-line fix, which keeps the two paths in sync.
|
Thanks for the review. I can fix the issue as well, but it needs some time as I'm pretty busy recently. |
Problem
If a user selects a specific browser for opening links and later uninstalls it, the app crashes every time they open a link. This is because the
catchblock reuses the sameIntent, which still carries the uninstalled browser's package name.Reproduction
Fix
Reset the package on the
ACTION_VIEWintent before retrying to fallback to other browsers.Note
The stale browser preference is not cleared, so every subsequent link still shows the "something went wrong" toast. Maybe we can also reset the preference.
Related