0

I'm trying to use an Intent to start an app for selecting a folder. I've looked at a lot of threads on this and I haven't found any with a solution other that those which have hardcoded references to specific apps like OI. For example: Intent intent = new Intent("org.openintents.action.PICK_DIRECTORY");

I keep getting these errors probably because my emulator doesn't have the right app on it:

  • //No Activity found to handle Intent { act=android.intent.action.PICK dat=directory:// }
  • //No Activity found to handle Intent { act=android.intent.action.PICK dat=folder:// }
  • //No Activity found to handle Intent { act=android.intent.action.PICK dat=content://vnd.google-apps.folder }
  • //No Activity found to handle Intent { act=android.intent.action.PICK dat=file:///storage/emulated/0 }
  • //No Activity found to handle Intent { act=android.intent.action.GET_CONTENT dat=file:///storage/emulated/0 }

I've found several sample apps that do return files or folders. I guess I'll grab one of them and rewrite it for my usage. I'd rather make the Intent used to start it as generic as possible and not hardcode the name of my app.

What are the pairs of Intents and intent-filters which I need to add the code to allow connection between some app and my file/folder selector program?

Aleksander Lidtke
  • 2,876
  • 4
  • 29
  • 41
NormR
  • 336
  • 3
  • 12
  • Have you looked at this post: http://stackoverflow.com/questions/9923760/how-to-use-intent-for-choosing-file-browser-to-select-file More specifically the link therein: https://code.google.com/p/android-file-dialog/ – Aleksander Lidtke Sep 24 '13 at 21:58

1 Answers1

1

What are the pairs of Intents and intent-filters which I need to add the code to allow connection between some app and my file/folder selector program?

There are no standards here that I am aware of, other than perhaps ACTION_GET_CONTENT for the */* MIME type.

Of your five bulleted attempts, only the fourth one would be considered generally valid:

  • The first two use schemes that may not be recognized
  • The third is tied to some Google ContentProvider
  • The fifth is malformed, as ACTION_GET_CONTENT is to pick by MIME type, not container

You are welcome to try to spearhead the definition of some standards in this space, or do what Aleksander suggests and use a library to provide this capability within your app rather than relying upon outside apps.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Spearheading is always fun, just a matter of how much time you've got for this project and how much effort you're willing to put in :) If selecting a folder or a file is all you need it shouldn't take much time to just build that into your app rather than using something external to it. – Aleksander Lidtke Sep 24 '13 at 22:20
  • The question is how to differentiate between asking for a file and asking for a folder. MIME type of * / * wouldn't say what was wanted. – NormR Sep 25 '13 at 01:10
  • @NormR: There are no "folders" in Android, any more than there are in a Web browser. – CommonsWare Sep 25 '13 at 11:08
  • @CommonsWare What do you call the "disk" component that holds files? I'm looking for the path to a place where the program can write a file. I want the user to be able to select that place. – NormR Sep 25 '13 at 12:03
  • @NormR: And for that, you are best off rolling your own UI. Like iOS and, as I understand it, newer versions of OS X, OS makers are trying to get away from files-and-directories. Hence, Android does not have a "folder" picker built in. – CommonsWare Sep 25 '13 at 14:00
  • How does one get to files that the browser puts in the Download "folder" if there are no folder navigation tools? – NormR Sep 25 '13 at 20:54
  • @NormR: Generally, it is the responsibility of the app that downloaded the file to provide means of accessing it. If you happen to be using `DownloadManager`, it will handle that chore for you, by showing a `Notification` upon download completion. – CommonsWare Sep 25 '13 at 20:56
  • None of my browsers do anything with what they put in the Download folder. I'll have to research how to use DownloadManager when using a browser that is downloading a file. Thanks for the advice. – NormR Sep 25 '13 at 23:59