android-components / mozilla.components.feature.app.links / AppLinksUseCases

AppLinksUseCases

class AppLinksUseCases (source)

These use cases allow for the detection of, and opening of links that other apps have registered an IntentFilters to open.

Care is taken to:

  • resolve intent// links, including S.browser_fallback_url
  • provide a fallback to the installed marketplace app (e.g. on Google Android, the Play Store).
  • open HTTP(S) links with an external app.

Since browsers are able to open HTTPS pages, existing browser apps are excluded from the list of apps that trigger a redirect to an external app.

Parameters

context - Context the feature is associated with.

launchInApp - If {true} then launch app links in third party app(s). Default to false because of security concerns.

browserPackageNames - Set of browser package names installed.

unguessableWebUrl - URL is not likely to be opened by a native app but will fallback to a browser.

Types

Name Summary
GetAppLinkRedirect inner class GetAppLinkRedirect
Parse a URL and check if it can be handled by an app elsewhere on the Android device. If that app is not available, then a market place intent is also provided.
OpenAppLinkRedirect inner class OpenAppLinkRedirect
Open an external app with the redirect created by the GetAppLinkRedirect.

Constructors

Name Summary
<init> AppLinksUseCases(context: <ERROR CLASS>, launchInApp: () -> Boolean = { false }, browserPackageNames: Set<String>? = null, unguessableWebUrl: String = "https://${UUID.randomUUID()}.net", alwaysDeniedSchemes: Set<String> = setOf("file"))
These use cases allow for the detection of, and opening of links that other apps have registered an IntentFilters to open.

Properties

Name Summary
appLinkRedirect val appLinkRedirect: GetAppLinkRedirect
appLinkRedirectIncludeInstall val appLinkRedirectIncludeInstall: GetAppLinkRedirect
interceptedAppLinkRedirect val interceptedAppLinkRedirect: GetAppLinkRedirect
openAppLink val openAppLink: OpenAppLinkRedirect

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.