Search code examples
androidandroid-intentandroid-activitysettingsfile-association

Android: programmatically access file associations


I would like to know if it is possible to access programmatically to file associations on an Android system, so that my app is able to know what app (if any) will be called if an intent is sent for a certain file.


Solution

  • so that my app is able to know what app (if any) will be called if an intent is sent for a certain file

    Step #1: Create the Intent in question.

    Step #2: Call queryIntentActivities() on a PackageManager to find all candidates, or resolveActivity() to find what will be launched if you were to just start an activity using that Intent. Note that resolveActivity() may point to the system chooser, if there are multiple candidates for that Intent and the user has not specified a default.