when i have to get some image or video
i did like this
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("video/*");
startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD);
and
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD);
i try to
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/* , video/*");
but in occured error
how can i solve that problem..
thanks your reply
Try this
final Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/* video/*");
startActivityForResult(galleryIntent, REQUEST_CODE);
have you tried with
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("media/*");
startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD);
Try this
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);
Works on 2.1
I was also having the same issue and I found the solution.
Intent pickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
pickerIntent.setType("image/*, video/*");
pickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"});
startActivityForResult(pickerIntent, REQUEST_CODE_FOR_MEDIA);
The key here is pickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"});
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("*/*");
photoPickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "video/* images/*"});
startActivityForResult(photoPickerIntent, REQUEST_GALLERY);
Related
String[] mimeTypes =
{
"application/acad",
"image/vnd.dwg",
"image/x-dwg"
};
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(intent, 9);
Intent intent;
String[] mimeTypes =
{
"image/*",
"application/pdf",
"image/x-dwg",
"image/x-dxf",
"image/x-3ds",
"application/zip",
"application/octet-stream",
};
intent = new Intent(
Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, 9);
After adding "application/octet-stream" .bin type my files are visible
This is our code for video picker, pretty much standard code. This code works in Android version before Nougat, however, it raises an exception in nougat.
private void pickVideoFromGallery(Activity activity){
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
intent.setType("video/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
activity.startActivityForResult(intent, MediaPicker.TYPE_FILEVIDEO);
}
And the exception is
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.PICK cat=[android.intent.category.OPENABLE]
typ=video/* launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
However if I uncomment following line, it starts working but that's not the solution as we are looking to select only openable videos
intent.addCategory(Intent.CATEGORY_OPENABLE);
Any idea?
Launch default file picker with videos.
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);
galleryIntent.setType("video/*");
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, galleryIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "File Chooser");
I am trying to allow a user to choose an image or video from his device, and currently it only shows video or image depending what is written first in the following code:
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//set type to include video too
galleryIntent.setType("image/*, video/*");
startActivityForResult(galleryIntent, GALLERY_IMAGE_REQUEST_CODE);
}
};
not sure what I am doing wrong, but setType seems right I tried with and without the comma in between image and video...
case 2: //Choose Pic
Intent choosePhotoIntent = new Intent(Intent.ACTION_GET_CONTENT);
choosePhotoIntent.setType("image/*");
startActivityForResult(choosePhotoIntent, PICK_PHOTO_REQUEST);
break;
case 3: //Choose Video
Intent chooseVideoIntent = new Intent(Intent.ACTION_GET_CONTENT);
chooseVideoIntent.setType("video/*");
Toast.makeText(MyActivity.this,getString(R.string.video_message), Toast.LENGTH_LONG).show();
startActivityForResult(chooseVideoIntent, PICK_VIDEO_REQUEST);
break;
Try above..you need to have separate options..
I ran into the same issue where it would only use the first MIME type in the list.
This ended up working for me:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("*/*");
String[] mimeTypes = {"image/*", "video/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
startActivityForResult(intent, REQUEST_CODE_CAMERA_ROLL);
This works for me:
Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(gallery, PICK_MEDIA);
I'd like the user to import a bunch of videos/photos into my app. This is the code I was using before:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setType("image/*,video/*");
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
The problem I'm having is that the above returns only Photos from the new Google Photos app. If I change the data type to 'video/*' only, the Photos app returns videos. This is for KitKat+
EDIT:
I've tried the following code - it works on some galleries but not with most and not Google Photos:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
if (AndroidHelper.isKitKatAndAbove()) {
Log.d(TAG, "Pick from gallery (KitKat+)");
String[] mimeTypes = {"image/*", "video/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
} else {
Log.d(TAG, "Pick from gallery (Compatibility)");
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
}
This is what I ended up doing:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
if (AndroidHelper.isKitKatAndAbove()) {
Log.d(TAG, "Pick from gallery (KitKat+)");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
} else {
Log.d(TAG, "Pick from gallery (Compatibility)");
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
}
Then when I get results, I check the type of the file. Seems to be working fine.
I do not speak English! Please people ignore.
I want save audio from
Intent intent = new Intent();
intent.setType("audio/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Select Picture"),
SELECT_PICTURE);
to other directories.
Try this
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
startActivityForResult(tmpIntent, 0);