Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more ActivityNotFoundExceptions #17914

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

lukstbit
Copy link
Member

@lukstbit lukstbit commented Feb 3, 2025

Purpose / Description

In both the shared decks screen and the account login the user could trigger an ACTION_VIEW(ex. mailto link) which went through our custom tabs implementation which finally tried to start and activity(and failed if no app to handle it was present).

Example bug report: https://ankidroid.org/acra/app/1/bug/280476/report/003eb5ab-bb37-484a-a3f7-0ec9bda1767c
Example stacktrace:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://ankiweb.net/... pkg=com.power.browser (has extras) }
	at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2100)
	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1747)
	at android.app.Activity.startActivityForResult(Activity.java:5473)
	at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.kt:704)
	at android.app.Activity.startActivity(Activity.java:5813)
	at androidx.core.content.ContextCompat.startActivity(ContextCompat.java:297)
	at androidx.browser.customtabs.CustomTabsIntent.launchUrl(CustomTabsIntent.java:662)
	at com.ichi2.compat.customtabs.CustomTabActivityHelper$Companion.openCustomTab(CustomTabActivityHelper.kt:167)
	at com.ichi2.anki.AnkiActivity.openUrl(AnkiActivity.kt:440)
	at com.ichi2.anki.MyAccount.initAllContentViews$lambda$13(MyAccount.kt:251)
	at android.view.View.performClick(View.java:7792)
	at android.widget.TextView.performClick(TextView.java:16112)
	at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1218)
	at android.view.View.performClickInternal(View.java:7769)
	at android.view.View.access$3800(View.java:910)
	at android.view.View$PerformClick.run(View.java:30218)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:226)
	at android.os.Looper.loop(Looper.java:313)
	at android.app.ActivityThread.main(ActivityThread.java:8751)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

How Has This Been Tested?

Just ran the tests.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

In certain screens of the app(like shared decks and account login) the
user could trigger an ACTION_VIEW from the content, which will
delegate to our custom tabs implementation. This will call the platform
launchUrl() method which would fail if there's no app to handle it.

Also added guards for the several extensions openUrl(), the check
AdaptionUtil.hasWebBrowser() is failing in a few cases.
Copy link
Contributor

@criticalAY criticalAY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niceee

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see how this could could possibly be wrong (those are probably famous last words, but whatever)

Thanks for checking on bug reports and posting up the fixes

@mikehardy mikehardy added this pull request to the merge queue Feb 3, 2025
Merged via the queue into ankidroid:main with commit 3f21e3c Feb 3, 2025
12 checks passed
@github-actions github-actions bot added this to the 2.21 release milestone Feb 3, 2025
@lukstbit lukstbit deleted the fix_activityNotFound branch February 4, 2025 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants