1

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.

P5music
  • 3,197
  • 2
  • 32
  • 81
  • provide intent filter for particular extension or mime type to handle.OS will automatically show your app to handle certain kind of file if it matches with filter. See this : http://stackoverflow.com/questions/1733195/android-intent-filter-for-a-particular-file-extension – Krupal Shah May 04 '16 at 16:44
  • @Krupal Shah My question is not about that, it's about how to gather information about file associations enforced on the system at a certain time – P5music May 04 '16 at 16:47
  • Ok sorry. my misunderstanding. I don't know the way but just curious : In what case do you need that information? – Krupal Shah May 04 '16 at 16:50
  • @Krupal Shah It could be useful for a file association manager app; my app needs to be sort of like that for certain file formats it can handle or let other app handle – P5music May 04 '16 at 16:57
  • Ok. There should be the way. wait for the answers otherwise we'll put a bounty on it. – Krupal Shah May 04 '16 at 17:01

1 Answers1

1

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491