I need to use the camera for my application with a countdown timer. That is, when called, the camera should open with an automatic 3-second timer via intent. So far, I am able to open the system camera, take a picture and save it. But now how to set an automatic timer?
My code:
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (cameraIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
Log.i(TAG, "IOException");
}
// Continue only if the File was successfully created
if (photoFile != null) {
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(cameraIntent, REQUEST_IMAGE_CAPTURE);
}
}
What you want would appear to be what I described in my comment as "you want to call
startActivityForResult()
, and then the camera should take a picture automatically in three seconds". That is what the timer option in the screenshot in your comment would do, AFAICT.If so, that is not possible in general. There are thousands of camera apps, both pre-installed on devices and available through distribution channels like the Play Store. Few have timers. None have to offer an API to allow you to configure a timer.
You can:
Try find a camera app that does have an API to allow you to configure a timer, then require the user to install that camera app
Integrate with the camera APIs directly yourself
Wait for me to add this to my CWAC-Cam2 library