androidandroid-intentandroid-activityintentfilterandroid-implicit-intent

How can i use implicit intent but avoid "select an app to handle this intent" screen?


In my code I want to trigger an implicit intent to open another android library activity.

Intent i = new Intent("Shared library", Uri.parse("https://www.google.com/"));
startActivity(i);

Lets say few apps contain this same library. If I trigger an implicit intent will the user see the "select an app to handle this intent"?

Or because all the apps contain the same library it will just open?


Solution

  • If I trigger an implicit intent will the user see the "select an app to handle this intent"?

    If the library:

    Then any app that incorporates the library and is not blocking that <activity> via its own manifest will be a candidate for responding to that implicit Intent. If there are 2+ of those apps, normal Android implicit Intent resolution occurs:

    Or because all the apps contain the same library it will just open?

    No, because Android does not know which app is the one that the user wants.

    How can i use implicit intent but avoid “select an app to handle this intent” screen?

    You can't, if the user has not set a default activity. It is up to the user to decide which app's activity should handle that implicit Intent.

    To put it another way: malware authors would love the ability to unilaterally hijack implicit Intents and force them all to route to the malware.