unable to open particular folder inside gallery - android

how i can open a specific folder in gallery.
ex :name of folder is my folder.
when user click Button it directly open my folder inside default gallery.
how can i do this?
Intent intent=new Intent(Intent.ACTION_VIEW);
Uri uri=Uri.fromFile(new File(Environment.getExternalStorageDirectory().toString()+"/video"));
intent.setType("video/mp4");
startActivityForResult(Intent.createChooser(openGallary, "Select Video"), 0);

This answer was given twice already. Please use Google first next time. The link that abbas.aniefa gave was my second hit on Google when searching "ACTION_VIEW specific gallery".
The answer is also given here.

Related

Android - how to open image in gallery with delete option

I use following code to open an image in the gallery:
public void onItemClicked(PictureItem item){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imageUri = FileProvider.getUriForFile(getApplicationContext(), "myapp.fileprovider", new File(item.uri.getPath()));
intent.setDataAndType(imageUri, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
This shows my photo in the gallery, but in a 'read-only' mode. I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Which action do I have to use for that? I do not want to use pick, just normal view with the option to delete. I tried ACTION_EDIT but it's not supported (and not quite the right choice neither ...).
I use following code to open an image in the gallery
First, there are hundreds, if not thousands, of "gallery" apps available for Android.
Second, your code simply asks to view an image (with a broken Intent due to your wildcard MIME type). There is no requirement for the app that responds to be a "gallery" app.
I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Then implement that yourself, in your own app, and get rid of the ACTION_VIEW Intent.
Which action do I have to use for that?
There is no Intent action that says "please display this image, but only if you are a gallery app, and, oh, by the way, you must offer a delete option", which appears to be what you want.

How to exclude specific directory from video picker?

I wish to select a video from User's gallery app, but I'd like to have one of the directories hidden from the video picker.
Directory "abc/" is visible in user's default gallery
In my app, user will pick a video from gallery
When he's picking a video using his gallery, directory "abc/" won't be visible.
What I currently do shows all directories available in the user gallery:
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
i.setType("video/*");
startActivityForResult(i, MainController.SELECT_VIDEO_REQUEST);
Is there any option that I could add to the intent to prevent my "abc" directory from being visible at picking time?
Is there any option that I could add to the intent to prevent my "abc" directory from being visible at picking time?
Not using ACTION_PICK. You are delegating this work to one of many possible apps. There are no documented extras for the Intent for "please hide this directory" or "please hide all videos whose names contain the letter 'q'" or anything like that. And, even if there were such an extra, apps implementing ACTION_PICK would be free to ignore it.
There are existing libraries for choosing files; one might meet your needs.
Just before you start the picker intent create an empty file with the name .nomedia in the abc directory.
In onActivityResult() delete the file again.

ACTION_GET_CONTENT on Kindle Fire HD for images returns data with file scheme instead of content scheme

I am facing a weird problem.
I have a form in my app where user will input some details and then select an image.
On pressing Submit, an email intent will be fired which will create an email draft with user's input pasted in mail body and his selected image attached to the email.
I have some code which works for Kindle Fire 1st Gen as well as other Android devices too. But the same does not work on Fire HD-7.
Here is the code to fire image selection intent.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(intent, "Select Media"), SELECT_MEDIA);
On 1st Gen Fire this works fine and returns:
content:///mnt/sdcard/Download/naturewallpapers252862529.jpg
But on Fire HD-7, it returns:
file:///mnt/sdcard/Android/data/com.amazon.photos/files/Pictures/Shared/naturewallpapers252862529 (7).jpg
And here's the most irritating fact:
CASE 1) On HD-7, if I select image from gallery, it creates a copy of the selected at "/mnt/sdcard/Android/data/com.amazon.photos/files/Pictures/Shared/" and returns this path which does not work with my code to create email intent with attachment. Also, it creates a new copy with (1), (2) and so on for same image every time I select the same image.
CASE 2) On HD-7, if I select image from ES File Explorer then everything works fine. It returns content:///mnt/sdcard/Download/naturewallpapers252862529.jpg uri with content:// scheme as against file:// in selected from gallery.
I am really out of any clues to get this resolved. Struggling since more than a week now.
Any help, any clues are highly appreciated.
Thanks,
Yogesh.

Opening Image File gives error in Android

I am trying to open a jpg image file in gallery. This gives a error. I am using the code below
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("/mnt/sdcard/image123.jpg"),"image/jpeg");
startActivityForResult(intent, 900);
This gives a option to open file in gallery. I select Gallery from the list. But it does not open up. I use ASTRO file manager and open the same image file. It opens up fine now. Please let me know if something is wrong.
Where do you got /mnt/sdcard. Try Environment.getExternalStorageDirectory().getAbsolutePath() instead.
Specified Image Path? You can't. Please Refer My Question as How to access different File Manager specific path. Refer this link and then you got a answer.

How to Attach File in Android and show specific icon?

I have a application requirement in Android. In my application I want to add files as attachments. This is to have it for quick reference.
In my layout I want to have a attach button. If the user clicks on the attach button he should get a file browser to browse the SD CARD. He must be able to select a file to attach.
I am not sure where to start of this code. I have placed a button and have a on click listener. But Inside the on click listener I am not sure what has to be done. Can you help me with some sample code or some links that can help me do it. Any kind of help is appreciated. Thank you.
You need an Intent to open up a file chooser. This is assuming the user has a file chooser.
int reqCode = 1;
Intent action = new Intent(Intent.ACTION_GET_CONTENT);
action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(action, reqCode);
Note reqCode is like a 'key' you use later. Next you'll override onActivityResult() in your Activity. When it runs, check to see if the requestCode matches your reqCode. If it doe, you know it's from your intent, and can get the data packed in the incoming intent.
This is just a brief overview, you should probably read up more on intents in the official documentation.

Categories

Resources