Open multiple images in gallery intent - java

I need to open multiple images in gallery to view by sliding...
I know how to open 1 image..
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);
How can i view multiple images to view them all by sliding in a single intent.?
I have the path of the images... And i need to view them in gallery.

The EXTRA_ALLOW_MULTIPLE option is set on the intent through the Intent.putExtra() method to select multiple images
Multiple Image selection available only for above API 18
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
Full intent code is here:
Intent intent = new Intent(); intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"),1);

You can straight away show multiple images by accessing into your device's default gallery app.
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);

There are 2 ways to implement multi-selection of images in gallery:
1.Intent for getting multiple images
2.Define custom gallery with fetching and loading photos from native gallery.
Intent for getting multiple images:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
For implementation of gallery see this link: http://www.technotalkative.com/android-select-multiple-photos-from-gallery/
it fetches multiple images and shows them in a gridview

No you cant do that.... You need to create a new view activity

Related

Intent Attach Data to set wallpaper android Getting Error on some devices

The same code works fine on some mobile phones but gives error on others
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(photoURI);
intent.putExtra("mimeType", "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startActivityForResult(Intent.createChooser(intent, "Set as:"), 7575);

Set orientation when picking a file from gallery

Currently I'm picking a file (Video) from the Gallery by doing:
private void selectVideo() {
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Video"), REQUEST_TAKE_GALLERY_VIDEO);
}
The above will open the Gallery and let the user select a file, this works perfect.
My question:
Is there a way to set a fixed orientation of the Gallery when the user selects a file? I can't find any information about this, is this even possible?

open Instagram hashtag intent

For opening an specific image in Instagram i use this intent:
Uri uri = Uri.parse("http://instagram.com/p/IMAGE_ID");
Intent insta = new Intent(Intent.ACTION_VIEW, uri);
if i want to see an specific hashtag all images what i have to do? Actually i want to open Instagram and see images of an hashtag
Uri uri = Uri.parse("https://instagram.com/explore/tags/your_tag/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

how to get a list of the installed audio players?

Is it possible to get a list of the installed audio players?
I guess I could do that as following.
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_SEND);
intent.setType("audio/*");
List<ResolveInfo> apps = getPackageManager().queryIntentActivities(intent, 0);
But I got nothing.
Could anyone help me? T_T
Try this:
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,"1");
intent.setData(uri);
intent.setType("audio/*");
List<ResolveInfo> apps = getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo rInfo : apps) {
//process list here
}
This code sniper lets you choose at first from you're installed audio players and then gives opportunity to play music from them.
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
intent.setType("audio/mpeg3");
startActivityForResult(intent, REQUEST_CODE);

Android gallery not updated after ACTION_IMAGE_CAPTURE

I'm using MediaStore.ACTION_IMAGE_CAPTURE to take a picture with MediaStore.EXTRA_OUTPUT to point to the Uri for the DCIM/Camera directory where all the other photo/video files are stored.
The photo file is successfully taken and I can see it using ES File Explorer and can view it inside my app. However it is not shown in the gallery when I use Intent.ACTION_PICK
Intent selectPictureIntent = new Intent(Intent.ACTION_PICK);
selectPictureIntent.setType("image/*");
I've read the other topics on updating the Gallery after the picture comes back using
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
and also
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, _outputMediaUri);
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent);
What's going on here :(
why did you use LocalBroadcastManager? LocalBroadcastManager can only send broadcast data inside of your app. Try to use
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, _outputMediaUri);
sendBroadcast(intent);
Gallery always listens to URI change. After file event broadcast to Gallery, the data stored in Gallery will be updated.
it also can problem with KITKAT build version.. for sure you can use this code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Intent mediaScanIntent = new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri contentUri = Uri.fromFile(out); \\out is your output file
mediaScanIntent.setData(contentUri);
this.sendBroadcast(mediaScanIntent);
} else {
sendBroadcast(new Intent(
Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://"
+ Environment.getExternalStorageDirectory())));
}

Categories

Resources