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.
Related
I built a face detection app that is working fine, the user can:
open the camera intent
take a picture
then it will screen this picture and tell if there is a face in it or no.
My idea is I don't need the user to open the camera from my app I need the user to open the camera
app in Android as normal, and then I will be working in the background reading the picture had been taken by his camera, analyse it and till by a toast if a face had been detected or no.
Not sure about if my application can detect if the camera had been opened or no and if opened can detect if phot had been taken or no, and if yes, can I read this image or no!!
If yes, how?!
Not sure about if my application can detect if the camera had been opened or no
Not really. You cannot detect what apps are in the foreground on modern versions of Android, for privacy and security reasons. And, even if you could, there are hundreds (perhaps thousands) of camera apps. You would have no reliable way of knowing whether any given app is really a camera app.
if opened can detect if phot had been taken or no
Not really. There is no requirement for a camera app to put its images anywhere that your app can access it. And, there is no reliable way to know whether any given file is a photo or not.
I am developing a Cordova camera plugin. When you open the camera, it allows the user to take the picture (first part) and then it takes the user to preview photo screen, where user can save or discard the image(second part). As per my requirement, I need to know when the user is at second part i.e. he/she is at 'save/discard' screen.
I was able to detect it in iOS via notifications. But I don't have any experience in Android so couldn't figure out a way.
Any help will be appreciated.
I am developing a Cordova camera plugin
According to your comment, you are using an existing Cordova camera plugin. I presume that you mean that you are forking that plugin and making changes to it.
That plugin is using ACTION_IMAGE_CAPTURE on Android to take a picture. This delegates to an external camera application. There are hundreds of possible camera applications that could handle the request. That includes pre-installed camera apps from thousands of Android device models.
I need to know when the user is at second part i.e. he/she is at 'save/discard' screen.
There is no requirement for developers of a camera application to offer the user a "save/discard" screen for ACTION_IMAGE_CAPTURE. Some may, some may not. For those that do, there is no requirement that they somehow tell other apps that the user is now on the "save/discard" screen.
Hence, there is no way for you to accomplish this, using the existing core logic in that plugin.
We were using Camera API for our custom camera application. However, it turned out to be a very hard problem. Many devices required extra testing as they seemed to perform unexpected behaviors. So, we have decided to migrate to Android's camera intent.
However, we are dealing with image retrieval tasks so, we don't want our users to send us blurry pictures. Previously, we were using autofocus as user taps on take picture button. Android camera intent performs worse than ours because it does not try to autofocus just before taking the picture. Android's camera does have such option but we don't want leave that decision up to our users because, they will probably will not select that option.
Is it possible to launch the camera intent with the option which auto focusses just before taking the picture? Thank you!
Is it possible to launch the camera intent with the option which auto focusses just before taking the picture?
No. The decision of whether or not to use auto-focus, or a flash, or any other camera feature, is between the user and the developers of the camera app. You do not get a vote.
So, I've come to find that the method of starting a camera intent provided by:
http://developer.android.com/training/camera/photobasics.html
Will eventually fail if you take a photo, and then hit cancel multiple times. I've tried it on other apps than the one I'm building and sure enough, the application also crashes after a few photos taken and cancelled. I assume this is because each photo remains in memory until returning to another activity. Combine that with the fact that hitting the cancel button does not produce an activity result in which to handle the previously taken picture, it seems like a limitation of the camera application itself.
My question is: Is there a way of getting around this while still using the built in camera application via intent? Is there a method I can call to keep it from caching the canceled images into memory?
it seems like a limitation of the camera application itself
Please bear in mind that there are hundreds of pre-installed camera apps (across thousands of device models and well over a billion active Android users), and countless more such apps on the Play Store and elsewhere, that might respond to ACTION_CAPTURE_IMAGE. While many have bugs, the bugs vary, and so the behavior that you are seeing is tied to that specific camera app that you happen to be invoking.
I assume this is because each photo remains in memory until returning to another activity
I certainly would not assume this, but if the other app is what is crashing, there is little that you or I can do about it.
Is there a way of getting around this while still using the built in camera application via intent?
You are not in position to fix all the bugs across all the camera apps across all the devices in use.
Is there a method I can call to keep it from caching the canceled images into memory?
There is nothing in the Android SDK for you to tell another app that it has a bug and should stop breaking.
According to Eric Ahn (Android - How to stop camera intent from saving on the phone) the only way around this is to create your own camera activity and handle the callbacks yourself via the camera's API. I'll probably look into it some more later, but I suspect Eric is right.
I would like to know if there is any way to use the front camera of the mobile without asking the persmission of the user while is using an application.
The logic would be:
User triggers something
The front camera starts recording
Records during 5 seconds and saves the file
The user can't know the camera did this. Is it possible? I guess I will have to indicate in the manifest the camera is going to be used, but that is ok, what I don't want is that the user has to confirm the camera usage or anything while is using the app.
Thanks
IMO this warning is a additional feature of google's android or the customized android versions from the manufacturers. I think it's a security feature, so you can't handle that behavior by your self.
This info is based on my opinion and talkings with front camera paranoid friends.