Skip to content

[Crash] ActivityNotFoundException when opening links while target app is hidden (OxygenOS) #1262

@Netrifier

Description

@Netrifier

Before you submit

  • I have searched the issue tracker for open and closed issues that are similar to the bug I want to file, without success.
  • I'm on the latest version

What happened?

When clicking the "Source code" button (or any button which opens a link), the app crashes if the OS-registered handler for that link is Completely Hidden.
This happened on OxygenOS using the system "Hide Apps" feature. The OS still treats the "completely hidden" app as the default handler for the link but prevents the app from being launched. As a result, startActivity() throws an ActivityNotFoundException, causing the app to crash.

How do we trigger it?

  1. "Completely Hide" an github app using Oxygen OS's "Hide Apps" feature.
  2. Ensure the "Open supported links" setting is enabled for that app.
  3. Try to click any button which opens a github link like the source code button on top bar or the Droid-ify version button in settings
  4. The app will crash
Stack Trace
12:18:07.239 com.looker.droidify AndroidRuntime: FATAL EXCEPTION: main
12:18:07.239 com.looker.droidify AndroidRuntime: Process: com.looker.droidify, PID: 7066
12:18:07.239 com.looker.droidify AndroidRuntime: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://github.com/... }
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2455)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:2030)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.app.Activity.startActivityForResult(Activity.java:6036)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at androidx.activity.ComponentActivity.startActivityForResult(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:8)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.app.Activity.startActivityForResult(Activity.java:5994)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at androidx.activity.ComponentActivity.startActivityForResult(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:4)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.app.Activity.startActivity(Activity.java:6491)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at androidx.fragment.app.Fragment.startActivity(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:11)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at com.looker.droidify.ui.appDetail.AppDetailFragment.onActionClick(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:48)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at com.looker.droidify.ui.tabsFragment.TabsFragment$$ExternalSyntheticLambda3.onMenuItemClick(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:19)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at androidx.appcompat.view.menu.MenuBuilder.performItemAction(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:21)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at androidx.appcompat.widget.ActionMenuView.invokeItem(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:5)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at androidx.appcompat.view.menu.ActionMenuItemView.onClick(r8-map-id-083991d2ac685e9477d042e5dc9b473992953c3fda8cc0d0c503a4a1729806bc:7)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.view.View.performClick(View.java:8119)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.view.View.performClickInternal(View.java:8089)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.view.View$PerformClick.run(View.java:31890)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:973)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:100)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:282)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.os.Looper.loop(Looper.java:387)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:9500)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600)
12:18:07.239 com.looker.droidify AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1005)

Your phone

OnePlus

Android version

Android 15 (OxygenOS 15)

Droid-ify version

v0.7.0

Anything else?

Workaround without unhiding the app

  • Disable the "Open supported Links" option in settings of the hidden app

Potential Fixes

  1. Use Intent with selector
    AppDetailAdapter.Action.SOURCE -> {
    val link = products[0].first.source
    startActivity(Intent(Intent.ACTION_VIEW, link.toUri()))
    }
            AppDetailAdapter.Action.SOURCE -> {
                try {
                    val link = products[0].first.source
                    val intent = Intent(Intent.ACTION_VIEW, link.toUri()).apply {
                        selector = Intent(Intent.ACTION_VIEW, "https://".toUri()).apply {
                            addCategory(Intent.CATEGORY_BROWSABLE)
                        }
                    }
                    startActivity(intent)
                } catch (e: ActivityNotFoundException) {
                    e.printStackTrace()
                }
            }
  1. Add a trycatch or use Intent
    onClick = { uriHandler.openUri(FOXY_DROID_URL) },

    onClick = { uriHandler.openUri(DROID_IFY_URL) },
        onClick = {
            try {
                uriHandler.openUri(FOXY_DROID_URL)
            } catch (e: ActivityNotFoundException) {
                e.printStackTrace()
            }
        },

Happy to open a PR implementing this if the solution looks good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions