- Home /
how to take a screenshot and save to image gallery on Android
I use Application.CaptureScreenshot(screenshotFilename) to capture and save snapshots, but the file is just saved in the application folder, it can't be accessed by the gallery or photosAlumb app, does anybody know hot to save the image to the gallery or photosAlumb?
Answer by foobuggy · Dec 09, 2013 at 09:27 PM
You should check the android developer site for information related to this:
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
Music/ - Media scanner classifies all media found here as user music.
Podcasts/ - Media scanner classifies all media found here as a podcast.
Ringtones/ - Media scanner classifies all media found here as a ringtone.
Alarms/ - Media scanner classifies all media found here as an alarm sound.
Notifications/ - Media scanner classifies all media found here as a notification sound.
Pictures/ - All photos (excluding those taken with the camera).
Movies/ - All movies (excluding those taken with the camcorder).
Download/ - Miscellaneous downloads.
Ultimately, you'd want to store (write the file using System.IO methods) the screenshot file to one of these directories and Android's built in MediaScanner should pick up on the newly added file. This will cause the image to appear in the device's gallery/photo list.
It really isn't this simple. Look at the link I've posted.
Android's $$anonymous$$ediaScanner is set to automatically update those default folder locations on all devices at regular intervals. On most devices, these are also pre-existing folders that live on an sd-card or in an emulated sd-card location. Perhaps I'm misunderstanding your question. Can you only save the screenshots to the application folder or would it be possible for you to save them into something like the pre-existing "Pictures/" folder so as to avoid the extra code needed to control the native processes? I've saved both image and audio files a number of times to these default folders on Android devices with no trouble at all in having them appear as ringtones or in the gallery. The only time it gets tricky is if you're forced to use a custom location. For that, you may need to use some native Android code to get the functionality required. I'm sorry if I misunderstood your question.
It's not my question. @hxflyer just wants to save the picture and see it in gallery. Saving in the right place isn't enough for most devices. As you've mentioned, it is a problem with media scanner and waiting for its regular interval is also not enough. In my tests on a few devices, only rebooting would make it work. But, I'll give you this, maybe this is all before android 4. I haven't tested this at all since the first android 4. (except the method with dll I've linked still works fine, obviously).
Here is the way to save your screenshot or texture to native gallery http://unitydevelopers.blogspot.in/2014/06/capture-and-save-to-camera-roll-and.html