You can install AndExplorer and use the Intent allowing to select a
file or directory.
Here is a code sample:
...
int PICK_REQUEST_CODE = 0;
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
Uri startDir = Uri.fromFile(new File("/sdcard"));
// Files and directories !
intent.setDataAndType(startDir, "vnd.android.cursor.dir/
lysesoft.andexplorer.file");
// Title
intent.putExtra("explorer_title", "Select a file");
// Optional colors
intent.putExtra("browser_title_background_color", "440000AA");
intent.putExtra("browser_title_foreground_color", "FFFFFFFF");
intent.putExtra("browser_list_background_color", "00000066");
// Optional font scale
intent.putExtra("browser_list_fontscale", "120%");
// Optional 0=simple list, 1 = list with filename and size, 2 = list
with filename, size and date.
intent.putExtra("browser_list_layout", "2");
startActivityForResult(intent, PICK_REQUEST_CODE);
...
...
protected void onActivityResult(int requestCode, int resultCode,
Intent intent)
{
if (requestCode == PICK_REQUEST_CODE)
{
if (resultCode == RESULT_OK)
{
Uri uri = intent.getData();
String type = intent.getType();
if (uri != null)
{
String path = uri.toString();
if (path.toLowerCase().startsWith("file://"))
{
// Selected file/directory path is below
path = (new File(URI.create(path))).getAbsolutePath();
}
}
}
}
}
...
You have the sample pop-up at:
http://www.lysesoft.com/support/forums/viewtopic.php?f=7&t=51
Hope it helps.
On Jun 23, 2:31 pm, Peli <[email protected]> wrote:
> I presume the video list activity has not been implemented
> cooperatively enough for ACTION_PICK.
>
> An alternative is to try to use ACTION_GET_CONTENT, which is taken
> better care of usually.
>
> Peliwww.openintents.org
>
> On Jun 22, 8:25 pm, silverburgh <[email protected]> wrote:
>
> > Thank you. I have tried to do the same thing for picking a video:
>
> > startActivityForResult( newIntent(Intent.ACTION_PICK,
> >
> > android.provider.MediaStore.Video.Media.INTERNAL_CONTENT_URI),
> > PICK_VIDEO);
>
> > But I only get a listView which shows the text of the videofilename.
> > And when I click on it, the video plays.
>
> > How can i get it to show a 'preview thumbmail' of each video? (like of
> > like how Gallery 'SelectVideo' works)? And when I click on it, the
> > video is selected , instead of playing it?
>
> > Thank you again.
>
> > On Sat, Jun 13, 2009 at 11:40 AM, Mark<[email protected]> wrote:
>
> > > I think you might want something like this:
>
> > > // start the image picker activity - the 999 is just a unique request
> > > code
> > > startActivityForResult( newIntent(Intent.ACTION_PICK,
> > > android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI),
> > > 999);
>
> > > at this point, the Gallery app will start and your app will pause
>
> > > To get the results (the selected image):
>
> > > // meanwhile, back in your activity...
> > > protected final void onActivityResult(final int requestCode, final int
> > > resultCode, finalIntenti) {
> > > super.onActivityResult(requestCode, resultCode, i);
>
> > > // this matches the request code in the above call
> > > if (requestCode == 999) {
> > > Uri _uri = i.getData();
>
> > > // this will be null if no image was selected...
> > > if (_uri != null) {
> > > // now we get the path to the imagefile
> > > cursor = getContentResolver().query(_uri, new String[]
> > > { android.provider.MediaStore.Images.ImageColumns.DATA },
> > > null, null, null);
> > > cursor.moveToFirst();
> > > String imageFilePath = cursor.getString(0);
> > > cursor.close();
> > > }
> > > }
>
> > > this will give you the absolute path to the selected imagefile.
>
> > > On Jun 13, 12:26 am, Meryl Silverburgh <[email protected]>
> > > wrote:
> > >> Hi,
>
> > >> Can you please tell me how can i launch theintentto pick image from SD
> > >> card?
> > >> Thanks.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---