tylerbwong / stack

An Android app for browsing Stack Overflow and other Stack Exchange sites.
https://stack.tylerbwong.me
GNU General Public License v3.0
510 stars 34 forks source link

No Fallback for Opening Links if Browser is Not Present #92

Closed tylerbwong closed 3 years ago

tylerbwong commented 3 years ago

Describe the bug For devices that do not have any browser installed/enabled, there needs to be a fallback for opening web links from within the app:

Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://stackoverflow.com/... (has extras) }
       at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2241)
       at android.app.Instrumentation.execStartActivity(Instrumentation.java:1895)
       at android.app.Activity.startActivityForResult(Activity.java:5205)
       at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:568)
       at android.app.Activity.startActivityForResult(Activity.java:5163)
       at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:554)
       at android.app.Activity.startActivity(Activity.java:5534)
       at androidx.core.content.ContextCompat.startActivity(ContextCompat.java:251)
       at androidx.browser.customtabs.CustomTabsIntent.launchUrl(CustomTabsIntent.java:376)
       at me.tylerbwong.stack.ui.utils.CustomTabsHelperKt.launchCustomTab(CustomTabsHelperKt.java:34)
       at me.tylerbwong.stack.ui.MainActivity$showLogInDialog$1.onClick(MainActivity.java:250)
       at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7682)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

This breaks login and other web links throughout the app.

To Reproduce Steps to reproduce the behavior:

  1. Remove/Disable all internet browsers on any device
  2. Open Stack
  3. Attempt to Login

Expected behavior The app should fallback to an internal WebView.

tylerbwong commented 3 years ago

~Fixed in 7688b137180996631fea61270160d9d0ec0ef986.~ Custom Tabs API already has this fallback.

tylerbwong commented 3 years ago

Need to potentially provide an internal WebView fallback. This happens for users that do not have a browser installed on device. (Nothing can resolve Intent.ACTION_VIEW).

tylerbwong commented 3 years ago

Temporary error handling in 15ccfa6f1677fba571a68da38aa76d7805c3a978. Will copy link to clipboard if no browser is found.