Is it possible to use ACTION_IMAGE_CAPTURE and customize some parts of the code? If yes, how?
I would like to add some Toast in the code. I know that there is the method onActivityResult to add some actions at the moment of the end of the activity.
But I would like to add some actions (ig. Toast) in other moments: for example when the user taps the screen to take the picture but before saving the picture.
Write your own camera app, where you provide an activity that implements ACTION_IMAGE_CAPTURE. Then, you can do whatever you want within that activity.
If, instead, you are asking how you can modify the code of hundreds of other camera apps that supply the world's ACTION_IMAGE_CAPTURE implementations, that is not possible.
Also, note that there is no requirement that the user tap the screen to take a picture using a camera app. They might set up a timer in the app, with the picture being taken after the timer elapses. Or, they might press a hardware CAMERA button, or press something on a Bluetooth remote, etc.
Related
I am just calling a camera intent like this:
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera, Constant.CAMERA);
Everything works fine, except when I start run this app for the first time.
I mean, if I wipe out data from my emulator, then start this app then,
The built-in Camera App shows some kind of first user tutorial if I start the camera intent.
After the tutorial, which is , even I take a picture, it does not show a confirmation check box. It keep stay as a built-in camera app and it does not return anything.
However, if I press back button and start the camera intent again, it works fine.
I am not sure how to prevent this kind of tutorial for the first time user.
I am not sure how to prevent this kind of tutorial for the first time user.
That is not possible. The decision of what a particular camera app will do in response to ACTION_IMAGE_CAPTURE is up to the developers of the camera app, not you or me.
Please bear in mind that ACTION_IMAGE_CAPTURE can wind up using any one of hundreds, if not thousands, of possible camera apps. The behavior of each of those camera apps will differ. And, since camera app developers do not seem to test ACTION_IMAGE_CAPTURE very much, you will get odd results like the one that you describe or various other things that you might consider to be a bug.
it's possible to disable/remove this photo confirmation dialog:
I need somehow skip this dialog but I still want use an Intent. I found this android: Take camera picture without "save" / "delete" confirmation but I don't want use SurfaceView .
I need somehow skip this dialog but I still want use an Intent.
That is not possible.
There are over 8,000 26,000 Android device models. Across them, there are hundreds of different pre-installed camera apps. Additionally, there are hundreds of additional camera apps that users can install from the Play Store or elsewhere. Any one of them could respond to your ACTION_IMAGE_CAPTURE request.
The protocol for ACTION_IMAGE_CAPTURE does not have an option for "do not show any sort of confirmation dialog". Some camera apps will have such a dialog, others will not. A few apps might have some undocumented Intent extra for controlling that behavior, but most will not.
Either:
Live with the confirmation prompt, where it exists, or
Do not delegate this work to a third-party app, but instead use the camera APIs to take a picture yourself (the SurfaceView approach that you rejected, though it does not necessarily need SurfaceView), or
Do not write the app
Use "android.intent.extra.quickCapture" in Intent.
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extra.quickCapture",true);
I am using some voice recognition on my activity. I have it set to open the camera intent using voice commands, but I'd also like to be able to have it snap the picture via voice. I know I could write this up using the camera object, but I'd rather keep using the intent because it offers more bells and whistles when not using voice.
I'm pretty sure this isn't possible but I'd love to be wrong here. Is there a way to call the capture button on the camera intent programmatically so I can leverage the voice commands to capture my image ie...if I say "take picture"...bam, picture is taken.
Ultimately, I'd also need to be able to programmatically hit the "confirm" button on the intent after the image is captured (or the cancel button), and then have it return to my calling activity.
It is not possible. You can't control other apps. The Intent is just a messages/event. When your app sends some Intent other app could receive it and decide what to do.
I think that the only way is to implement your own camera. By the way there are lots of open-source camera apps. For instance: https://github.com/CyanogenMod/android_packages_apps_Camera.
I want to write application on Android that starts in background when user launches a built-in camera (it is important: build-in camera, not an application) and do some actions after user makes a photo.
Is it real? If yes, how to implement this?
I doubt if this is possible. There is no mechanism which android provides that causes a broadcast to the system that Camera has been launched. Plus, you cannot modify the contents shown on the screen as the Camera application is in command. The only way out is to have a MediaScanner and FileObserver to check when a new picture is created in DCIM/Camera/ folder and make your app act accordingly
Upon starting my Android app, I want to auto start the native camera (can be done using intents) and start taking pictures automatically for every few seconds.
Can this be done? After starting the camera, how do I initiate this? So that user need not click anything to start the photo taking process.
Thanks In Advance,
Perumal
There is no support in the camera intents for autocapture. If you want to do that you'll need to actually implement the camera code within your app.
If you are using intent, you just fire up installed camera application and have no firther control. If you like to capture images periodically and be in control, you have to use camera service yourself. Here (in source repo) you can find a sample how to fire up camera and capture previews:
http://sourceforge.net/projects/javaocr/
Keep the button there but set the visibility to gone so that user doesn't see the button.
When you open the camera, use a timer task and then inside the timer task just write:
button.performClick();
here button is the reference to your Button or whatever view you are using.
This will capture images automatically, after the time specified by you.