I have a button in my app. With an OnClick event to the button I launch the default camera app.
public void startrec(View v) {
Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
startActivity(intent);
}
This works fine. Now is it possible that the camera starts recording automatically without I have to press the record button in the camera application? So I mean... I press my button in my app -> the camera app starts -> the record starts immediately
How can I do that?
How can I do that?
Record the video yourself, using classes like MediaRecorder.
Your existing code is asking a third-party app to take a video on your behalf. There are hundreds, perhaps thousands, of such apps. The behavior of each of those is up to the developer of those apps. There are no documented extras for your chosen Intent action, let alone one for your desired feature. And even if it existed, not every camera app would honor it.
Related
I want to force user to click image once camera opened, he should not go back without clicking image via back button.
Please suggest me how to implement force click or disable intent camera back button in android.
That is not possible, sorry. If you need that degree of control over the camera, do not use an Intent to launch some third-party camera app. You will need to write your own camera logic, using the camera APIs or a library wrapper around them (CameraX, Fotoapparat, CameraKit/Android, etc.).
I am currently using the default camera to take photos for my app.
It currently displays Retry and OK buttons at the top of the screen when launched, is there any way of adding cancel to this, which would return the user to the app?
No, it is not possible. Since we launch the default camera app with startActivityForResult(), which means you are kind of moving out of the app and seeking Result on completion of task on the CameraIntent. Customizing Camera intent is in not your hand untill Camera app exposes some API to do so(which is not yet available).
In my App I use ACTION_VIDEO_CAPTURE to record video.
But Now I have to start record when I start Activity.
How ro start ACTION_VIDEO_CAPTURE and start recording automatically?
Or if it's impossible how to add listener to record button (ACTION_VIDEO_CAPTURE) or check when this button was clicked?
How ro start ACTION_VIDEO_CAPTURE and start recording automatically?
You don't. There is nothing in the ACTION_VIDEO_CAPTURE protocol that allows you request, let alone control, how the third-party camera app allows the user to start and stop the video.
how to add listener to record button (ACTION_VIDEO_CAPTURE) or check when this button was clicked?
I do not know what "record button" you are referring to. If you are referring to a button in the third-party camera app, there may not be a button. The third-party camera app may use a tap on the preview image, or a gesture, or a timer, or whatever the developer of the third-party camera app wants to do. Moreover, all of that is inside the third-party camera app, and you have no good way of finding out when those events occur, if at all.
If you need this level of control over video recording, record the videos yourself using MediaRecorder.
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 am trying to take multiple photos using the default device camera application launched through an intent (MediaStore.ACTION_IMAGE_CAPTURE). With the devices I am testing with, the camera launches, takes a picture, asks for confirmation, then returns to my activity where I process the result.
I've considered using broadcast receiver callbacks or a content observer; however, I cannot find a way to launch the camera and keep it active until the user is finished. If possible, I wish to avoid developing a custom camera application.
The reason I must do this is because users commonly need to take multiple photos in succession, and on some devices the camera start-up time is upwards of 5 seconds, and the users using the software take 10 - 30 photos consecutively; not only that, but they need control over various camera parameters.
Is there a way to launch the camera intent and only return to my activity once the user exits the camera application?
I discovered through the SDK documentation that there's an alternative intent action for the device camera that launches the camera in still image mode and does not exit until the user is finished with the activity:
Intent intent = new Intent(
MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
this.startActivity(intent);
Coupled with a ContentObserver this was exactly what I needed to accomplish.