Two risks should be taken into consideration before camera photography can be used.
[1] Not every android machine can use your application
Main reasons:
The camera takes pictures. The app calls the android system API, the system API, and the underlying driver. The app calls the underlying driver hardware.
Generally, android mobile phones have a vendor-defined write driver to implement the operating system, and some customized small manufacturers' android system API implementations are not complete, or are not supported. As a result, an exception occurs when your application is installed.
[2] The response time varies depending on different models and brand machines.
Main reasons: Currently, the performance of the android mobile phone is still limited. The response time of the mobile phone hardware is not the same for different configurations. Example: Call the lens, the initialization time of the lens, the time when the camera responds to the camera instruction, etc.
Frontier:The practical application of this Article is timed continuous photo taking, and there is no flash or sound during the photo taking process. The following is a summary of the camera calling during the application implementation process.
1Step 1Initialize Camera
Initialization Process
Get a Camera instance
camera =Camera.open();
Set the camera parameters (no flashlight and the camera angle turns 90 degrees). Note: The default camera is a horizontal camera)
Camera.Parameters parameters=camera.getParameters();
parameters.setFlashMode("off");
parameters.set("rotation",90);
camera.setParameters(parameters);
Enable Preview (you must call this function before executing the camera command)
camera.startPreview();
2Set the camera instruction and callFeedback events to get and store photos
Set feedback events:
PictureCallback pictureCallback=new PictureCallback(){
public void onPictureTaken(byte[] data,Camera camera)
{
FileOutputStream outSteam=null;
try{
SimpleDateFormat format=new SimpleDateFormat("yyyyMMddHHmmss");
String times=format.format((new Date()));
outSteam=new FileOutputStream("/sdcard/MyImages/"+times+".jpg");
outSteam.write(data);
outSteam.close();
}
catch(FileNotFoundException e)
{
Log.d("Camera", "row");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
};
};
Execute the photo instruction
3After taking the photo, release the camera.
camera.takePicture(null, null, pictureCallback);
4Configure permissions:
Set camera permissions in the AndroidManifest. xml file
<Uses-permission android: name = "android. permission. CAMERA"/>
Note: The current application has been released:
Http://www.appchina.com/soft_detail_180936_0_10.html