HelloEveryone! I want to know some principal thing. Is there exists a method to take a picture (with good resolution) from android device without saving it in hard memory (only in RAM). I tried to:
use TakePicture(shutter, raw, jpg), but resolution of the resulting JPG is very low and RAW working with very few number of devices. Was asked here
give the control to Google Camera, but this way required some temporary file in the hard memory (to write picture)
How can I do this. Or is it impossible? Any help! Thank you!
It depends on your phone. Many phones do not need external sd card because they already have a internal one. So I suggest you check the hardware information of your phone first. If it do not have a external sd card, you can try to use camera2
to take videos and pictures. Pictures and videos can be stored in RAM. But if you want to access the pictures stored in RAM, you need to root your phone first.
Related
I want to query the MediaStore for all photos on the device, but only those taken by the camera. Please note the distinction I'm trying to make on photos vs any other image media (downloads, screenshots etc) on the device. The MediaStore contains many different directories, or "buckets", where the default camera/pictures location is one of them. However, there doesn't seem to be any standard on what this bucket is named -- on my Sony Z5, it's "100ANDRO", on my Samsung Galaxy S3, it's simply "Camera".
Reading various posts on StackOverflow, it seems this varies with manufactorer, but I should be able to find the path to the conventional "camera folder" at
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
So I can filter the query to MediaStore on that path (e.g. /storage/emulated/0/DCIM on my S3). If the user chooses to store the photos at a totally unconventional location, perhaps using a third-party camera app, then that's OK. I'm only hoping to cover the most "normal" use cases here.
But what if I want to load also the photos on an external SD card, if present?
As far as I can see, the photos on the "internal memory" and those on the SD card will have the same BUCKET_DISPLAY_NAME (and BUCKET_ID) in the MediaStore. But getting the path to the SD card photos directory seems to be very difficult across devices.
So what do you think about this approach (to get all photos):
find the "camera folder" path (as above)
query the MediaStore, filtered on this path. Find the corresponding BUCKET_DISPLAY_NAME
query the MediaStore again, filtered on BUCKET_DISPLAY_NAME from step 2, and where the path differs from that in step 2.
Step 2 will find all the photos on the internal memory.
Step 3 will find any photos on the SD card, if present.
Step 3 will be empty if no card is mounted, or if it contains no photos, so this might seem to be a rather graceful approach.
So I can filter the query to MediaStore on that path (e.g. /storage/emulated/0/DCIM on my S3)
You can achieve that with the code in that link you found, it's the best solution you'll find, yet, like others have said, you have no guarantee that the device's camera app is actually storing pictures inside a directory at Environment.DIRECTORY_DCIM, and there's even the problem that other apps might also be using it to store any images, other than pictures, since it's public...
I am a bit confused on where and how Camera images get stored. So I have an API 22 emulator ran on an SD and the below code will only work if ran using an SD card. I then take a couple of pics and see the pictures in the gallery and the camFiles array will get populated.
However, it does not work with API 23/24 emulators even with SD card. Is there a way to get the default camera directory that'll work for any API level?
File cameraDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString());
File[] files = cameraDir.listFiles();
//gets the 'Camera' directory
File finalCamDir = files[0];
File[] camFiles = finalCamDir.listFiles();
Is there a way to get the default camera directory that'll work for any API level?
Not really. There is no single "default camera directory". There are thousands of Android devices, with hundreds of different pre-installed camera apps, in addition to camera apps that users install themselves. It is up to the developers of those camera apps to decide where to save photos on the device.
DIRECTORY_DCIM is a recommended starting point. Some camera apps will put photos directly in this directory. Others, such as Open Camera, will use a subdirectory off of DIRECTORY_DCIM (e.g., OpenCamera/). Others are welcome to store their photos wherever they want, not necessarily involving DIRECTORY_DCIM.
I am working on an Android app which uses the camera intent... I'm working on my Samsung Galaxy S6 which has no SD card. By following the official documentation tutorial, I am able to get the thumbnail version of the photo taken. However, every tutorials I can find to retrieve the full size version includes the use of an external storage (SD card). So my question is : how can I get the full size version of the photo taken when no external storage is available ?
Thanks!
You don't need an SD card to use getExternalStorage(). Have you actually tried using the code on your Galaxy S6? If so, what issue exactly have you encountered?
We are making an app that will be basically the home for some Android devices.
Based on that, the idea is to have different partitions, for example, one for videos, one for apps and one for photos. What we want to achieve here is to prevent someone uses the entire storage capacity in recording a video, so with these partitions you can make videos until the videos partition gets full, and if this get full you still can install apps and take pictures.
So, here is the question. Is this doable? I know we have the option to make this via "logic", using folders and maintaining the used space count and make some validations. But the partitions approach seems to be more "clean and clear".
Can we make multiple partitions (external or internal storage)?
Can we save files to specific partitions? (I know that Android 4.4 provide some way of doing something similar but we are using Android 4.0/4.1)
Thanks in advance.
i edited an existing emulator to have an sd card of size 9mb and i added a boolean in the hardware section to support sd card. when i start the app it says "your SD card is full", what do?
First, try making the SD card larger - like, 100 MB - and restarting the emulator. The boolean in the hardware section, IIRC, triggers the preferred location for the application's APK - internal memory or SD card. An APK of 9MB is not that uncommon.
The problem is that your SD card size has been declared too small. Consider the practicability of a user having a 9MB SD card when the whole world is talking in GBs.
Edit the emulator and increase the size, atleast to a hundred as depending upon your application, you might be needing a lot of space.
However, see this post regarding a known issue on SD card size.