Using Intent.Action_Pick for Specific Path

Using Intent.ACTION_PICK for specific path

Sorry, no this is not possible.

Also you are using this Intent protocol wrong. As per http://developer.android.com/reference/android/content/Intent.html#ACTION_PICK this protocol expects that you put the content: URI of the data set you want the picker to select from.

That said, you should consider ACTION_PICK deprecated. The modern action is ACTION_GET_CONTENT which is much better supported; you will find support of ACTION_PICK spotty and inconsistent. Unfortunately, ACTION_GET_CONTENT also does not let you specify a directory.

How to select a video from the gallery and get it's real path?


Here is the full code to get the video path after selecting from gallery.

Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Video"),REQUEST_TAKE_GALLERY_VIDEO);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) {
Uri selectedImageUri = data.getData();

// OI FILE Manager
filemanagerstring = selectedImageUri.getPath();

// MEDIA GALLERY
selectedImagePath = getPath(selectedImageUri);
if (selectedImagePath != null) {

Intent intent = new Intent(HomeActivity.this,
VideoplayAvtivity.class);
intent.putExtra("path", selectedImagePath);
startActivity(intent);
}
}
}
}

// UPDATED!
public String getPath(Uri uri) {
String[] projection = { MediaStore.Video.Media.DATA };
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
if (cursor != null) {
// HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL
// THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} else
return null;
}

How to open specific folder in the storage using intent in android

This code may help you:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, YOUR_RESULT_CODE);

If you want to open a specific folder:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

intent.setDataAndType(Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ File.separator + "myFolder" + File.separator), "file/*");
startActivityForResult(intent, YOUR_RESULT_CODE);

Unable to select particular images using ACTION_PICK intent

hops this will helps you ....

ACTIVITYRESULT_CHOOSEPICTURE is the int you use when calling startActivity(intent, requestCode);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == ACTIVITYRESULT_CHOOSEPICTURE) {
BitmapFactory.Options options = new BitmapFactory.Options();
final InputStream ist = ontext.getContentResolver().openInputStream(intent.getData());
final Bitmap bitmap = BitmapFactory.decodeStream(ist, null, options);
ist.close();
}
}

if above code doesn't work than just refer this link... it will surly shows the way

http://dimitar.me/how-to-get-picasa-images-using-the-image-picker-on-android-devices-running-any-os-version/

opening an image using Intent.ACTION_PICK

ACTION_PICK is to allow a user to select an image from any of the installed apps which registered for such an action. It is not possible to specify from which album to select. It is at the user discretion to decide which app to use and to browse to the desired album to select the photo.

So taking out the folder parameter, you can try this:

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, REQUEST_CODE_LOAD_IMAGE);

And in the onActivityResult, besides the RESULT_OK, you should also check for data.getData() != null, as an app could close correctly (not cancelling) without returning an image at all.



Related Topics



Leave a reply



Submit