open gallery from android studio folder rather than the phone photo gallery - android

I have a activity that select image on the android photo gallery
Intent intent = new Intent(Intent.Action_PICK, MediaStore.Images.Media.INTERNAL_OCNTENT_URI);
but I want to choose images from my android studio drawable folder instead.
how should I modify the code?

You don't permission for that and that question is already asked
Link here

Im afraid there is no ACTION_PICK for picking images to project's folder.
But, you may create your own UI to show the images from your project's folder by getting the images using getIdentifier() as suggested from the link that Manjeet Deswal's answer provide

Related

Android open gallery with local (from 'res' folder) images

Is it possible to open Android Gallery for image selection (like ACTION_PICK intent for images from camera and other apps) but make it to show ONLY images stored locally in our app ('res' folder)?
The use case for this is to provide option to select app background from provided images.
No, it is not possible. App assets are not available to standard Gallery application
The standard "gallery" <intent-filter> does not include support for app resources at all.
The use case for this is to provide option to select app background from provided images.
Use your own ViewPager, or GridView, or StaggeredGridView, or AndroidStaggeredGrid, or whatever.
Closest I can think of is using a custom content provider, and maybe using ACTION_PICK with a uri that your content provider responds too?
This is more of a guess than an answer.

Show only folders in Gallery that are on phone

My app has a built-in cropper. I want the user to select photos from the Gallery but only folders that are on the phone. By default, the Gallery shows all folders including those from PicasaWeb.
Thanks in advance.
You need to add an extra to your intent.
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
Android image picker for local files only

How to avoid saving picture at gallery or delete it automatically in Android?

The device is Samsung Galaxy III. I developed an APP to run the camera activity and capture an image. After analyzing the image, I print out some text information. Right now every captured image is saved at gallery. I don't need the image to be saved in gallery or SD card. I think either of the following two solutions will work for me, but I don't know how to program it:
avoid saving pictures to gallery.
delete the picture somewhere in the APP.
Any comments are appreciated.
Read Android Camera tutorial.
...
Storage - Are the images or videos your application generates intended to be only visible to your application or shared so that other applications such as Gallery or other media and social apps can use them? Do you want the pictures and videos to be available even if your application is uninstalled? Check out the Saving Media Files section to see how to implement these options.
or see this one: How to save image captured with camera in specific folder.
In the Camera intent when starting, add this:
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(getTempFile(context)));
I solved my problem with following two steps:
as '#auselen' pointed, save all the images to a specific folder. How to save image captured with camera in specific folder.
delete all the images in that folder somewhere in the APP. How to Delete Image From SDCard in Android
use this for delete a pic
ImgPhoto1.setImageBitmap(null);

Android ACTION_VIEW Multiple Images

I have between one and three photos I'd like my app to display. I won't know until runtime exactly how many photos are downloaded from the Internet.
I can't figure out how to create an Intent to display the photos. Right now I'm caching them on the sdcard under a folder I create by doing something like (sans error checking):
final File externalDirectory = Environment.getExternalStorageDirectory();
final String folder = externalDirectory.getAbsolutePath() + "/Android/data/" + packageName + "/files/";
This was explained in the Android Developer Reference.
I can get one photo to display by doing the following:
final Uri uri = Uri.fromFile(file);
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/*");
Util.startActivity(this, intent);
Where file is the file of a saved photo.
If it helps, I could save the images to any location available to my app, however I would prefer to not have the photos show up listed with the user's other personal photos as that may be annoying.
The Image Viewer has a menu option "Slideshow", so it must know about multiple photos.
I could create my own Image Viewer, but that seems like extra work and beyond what I would I reasonably expect. Even if I did this, I would like the user to be able to install a 3rd party Image Viewer and get a better experience with pan, zoom, share, ...
I tried using the directory of the cached photo files to create the Uri, but the Image Viewer shows a black page. If I pass in the file, it shows just that one file and no others.
I know this must be possible because I can see use the Gallery app and show the photos if I manually select the folder. Everytime I research this issue, the comments say it's not possible to show multiple images.
I suspect there's some magic incantation, but what?
I think your goal is out of your control. If the viewer app is designed to handle mutiple images or a directory, you may ask it to show as you want, but you are defined to the viewer's pattern.
I have installed a third-party image viewer called QuickPic. I just tested your code snippet and the system popped up a chooser dialog to let me select the app to show the images in the folder. If I select native gallery, what I see is just an empty folder, while the Quickpic works as I want.
PS: I tell my app the Uri of the folder this way:
intent.setDataAndType(Uri.fromFile(new File("//mnt/sdcard/test/")), MimeTypeMap.getSingleton().getMimeTypeFromExtension("png"));

Android, Pick Image

Is there some possible way of picking images from picture folder?
Basically you call the gallery intent and expect a result with onActivityForResult
Have a look here:
How to pick an image from gallery (SD Card) for my app?
Further searching in SO yields this, a complete solution:
Get/pick an image from Android's built-in Gallery app programmatically

Categories

Resources