Skip to content

[Bug]: ActivityNotFoundException is thrown when no intent can handle the open of the browser #283

@LisandroDiMeoCntr

Description

@LisandroDiMeoCntr

Description

Summary

We have observed users facing an ActivityNotFound exception when a call to login is done. Apparently it happens when the SDK can't detect an application to handle the intent:

Fatal Exception: android.content.ActivityNotFoundException:
       at net.openid.appauth.AuthorizationService.prepareAuthorizationRequestIntent(AuthorizationService.java:555)
       at net.openid.appauth.AuthorizationService.performAuthManagementRequest(AuthorizationService.java:339)
       at net.openid.appauth.AuthorizationService.performAuthorizationRequest(AuthorizationService.java:228)
       at net.openid.appauth.AuthorizationService.performAuthorizationRequest(AuthorizationService.java:175)
       at io.fusionauth.mobilesdk.oauth.OAuthAuthorizationService.authorize(OAuthAuthorizationService.kt:141)
       at <package_name>.FusionAuthManager.login(FusionAuthManager.kt:55)



suspend fun login(successIntent: Intent, cancelIntent: Intent) {
        AuthorizationManager
            .oAuth(context)
            .authorize(
                successIntent,
                OAuthAuthorizeOptions(
                    redirectUri = redirectUri,
                    cancelIntent = cancelIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP),
                ),
            )
    }

At the moment, we can catch that exception and present a retry to the user, but it would be great to receive (in the case of a user with no browser available) a message to explain this situation, although it's strange that they don't have a web browser that can handle this.

Affects versions

We are running FA version 0.2.0

Steps to reproduce

In a device with no active browser (for instance, go to chrome and disable it), attempts to call:

AuthorizationManager
            .oAuth(context)
            .authorize(
                successIntent,
                OAuthAuthorizeOptions(
                    redirectUri = redirectUri,
                    cancelIntent = cancelIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP),
                ),
            )

will result on ActivityNotFound exception

Expected behavior

It's expected to have either an error from the SDK, or open it on the WebView (should be always available)

Screenshots

No response

Platform

  • Device: Any Android w/o active browser. We observed this specially on Samsung devices.
  • OS: We observed this on Android > 13

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions