I have a multi platform app - iOS and Android.
One of the features in the app is to capture images. I have a toggle switch in the app settings which allows the user to save the image to the device picture album if the switch is enabled.
This is an issue I can only produce in Android. Even without the toggle switch enabled, the captured photos still save to the device. I have tested this on Android 4.4.2 and 6.0
It does not do this in iOS.
There is nothing in my code to suggest that the photo should still be saved, I have checked it over and over.
Has anyone else come across this? If so what can be done to rectify the issue?
Thanks,
This is simply how FireMonkey captures images on Android. It saves a captured image to a file before handing the pixel data to you. And it does not provide access to the captured image's filename so you can remove the file afterwards.
FireMonkey has an IFMXCameraService interface with a TakePhoto() method, which accepts a NeedSaveToAlbum option:
Taking Pictures Using FireMonkey Interfaces
However, it is currently broken on Android:
RSP-13118: [Android] TTakePhotoFromCameraAction saves Image on Disk unexpectedly
RSP-15820: IFMXCameraService TakePhoto , NeedSaveToAlbum False not working
Until that is fixed, you could use JNI to access Android's camera APIs directly, then you can do whatever you want with the images.
Related
I'm learning android studio and I'm currently working on a robotics project in which an Android phone is placed on the robot and used as the processor, therefore I can't reach the phone by hand. The phone needs to do some image processing. And it's not a real-time processing so I need to take a photo (Preferably Bitmap) whenever I want, quickly and without preview and confirmation. I've tried some tutorials and they all open the camera app and the user needs to capture and then confirm the photo.
I don't have problem with the processing and I don't need to use openCV etc. I just need help with capturing the photo. Thanks
You can implement your own camera, either via the camera APIs (hard) or by using a library (CameraKit-Android, Fotoapparat, etc.), thank you will have control, you can directly save the image without previewing it
I'm using a chooser to allow the user to pick a photo from his gallery or take a new one using his camera (I copied the code from this answer).
Picking an image from the gallery works perfect. The problem is that when I capture an image with the camera It's not returning to the app and just stays in the confirmation screen...
I actually don't even need this screen to be displayed in the first place...
Can I somehow disable it or (if not) just make the Done button work?
Thanks in advance!
Can I somehow disable it
No.
just make the Done button work?
Contact the developers of your camera app, and point out the bug. Perhaps someday they will fix it.
You are using ACTION_IMAGE_CAPTURE. This launches a third-party camera app, to take a picture. There thousands of Android device models. These ship with hundreds of different pre-installed camera apps, and there are many more available for download from the Play Store and elsewhere. Any could be the one that handles a given ACTION_IMAGE_CAPTURE request, and any of them can have bugs.
I know how to make a preview and capture images inside an app.
However, I want to make a "capture mode". In this mode, the user may close my app and any pictures that get taken in other apps such as the default camera app get sent to my app, so I can make a gallery of them in my app.
I have an app which has a button that switches capture mode on and off, but how do I make it listen to camera events happening elsewhere? Would I have to search through the gallery for pictures taken in the time frame that capture mode was on?
Check out http://developer.android.com/reference/android/provider/MediaStore.Images.Media.html to find images located on the phone's internal or external storage during a specific time frame.
If you are doing any sort of work on these images, you could also investigate using a Service to ensure that your app can process the images while the other apps are running, but this hopefully won't be necessary.
My company has a need to print a timestamp on images taken on a droid. Another developer mentioned that we could wrap the entire functionality of the stock camera, then once a photo is taken, embed the timestamp on it. Can this be done, and if so, how simple/complex would it be?
Pretty simple actually. Definitely way simpler then writing a camera app from scratch.
Here is a short overview to give you a few keywords:
You need to fire a ACTION_IMAGE_CAPTURE intent,
this launches the devices camera app and prompts the user to take a picture (stock app or not doesn't even matter). When the picture is taken it will return to your app¹. At this point you'll get a file URI of the taken image that points to a JPEG usually.
Once you have that, load the image via the BitmapFactory into a Bitmap object and edit it by using a Canvas. You can use Canvas.drawText() to draw the text. Then store it where you need it, send it off the device or do whatever you want with it. And that's all the magic.
¹ here is a small example how to do that, found via google, there are plenty more out there
Images on the Android device can originate from many different sources - from the device camera, from an external SD card, from an e-mail, synced from another system. I'm developing an application which uploads images from an Android device to a web application. It turns out that the web application can perform some significant optimizations if it can be determined that the uploaded image originated from the device's camera.
I guess that this would have to be done at the point that the Android application user selects the image from those presented in the picker. At that point, the Android application has an image in hand. Is there image metadata available, and, if so, would it include a marker which indicates that the image originates from the device's camera?
Thanks for any thoughts.
Peter Hornby
Peter,
If you view the EXIF data for the JPEG you should be able to see the camera type it was taken with. On my droid it says "Motorola Droid" for the camere type.
Here is a link to an android class for reading EXIF data: http://android-er.blogspot.com/2009/12/read-exif-information-in-jpeg-file.html