Com. Android. Camera. Camera

Source: Internet
Author: User

1.In the oncreate method:

1.1Call the getpreferredcameraid () method. In this method, the combopreferences object is added, which is used to manageProgramThe configuration file generated in the package name. After obtaining this object, some configurations are initialized. Then read the camera ID mcameraid from the configuration file and call util. the getcamerafacingintentextras (this) method is obtained through "android. intent. extras. camera_facing "gets the ID passed in intent. If the ID is valid, it overwrites the previous mcameraid.

1.2The focus mode in the configuration file is stored in the defaultfocusmodes array. Initialize mfocusmanager to manage the focus mode. Use the sub-thread mcameraopenthread to start the camera. Determines whether the Boolean value of the quick photo request is stored in misimagecaptureintent (a third-party application request ).

1.3Initialize some view objects. Create a new configuration file and store the current camera ID in the configuration file created by mpreferences. the number at the end of the configuration file indicates whether the front camera and back camera are used. Obtain the number of cameras (mnumberofcameras. Call the resetexposurecompensation () method to set the exposure value in the configuration file to 0. Call util. enterlightsoutmode (getwindow () to hide the title bar and set full screen in the configuration file.

1.4Initialize surfaceview, Get holder, and set to retrieve pixels from the outside to add a listener. Wait until the sub-thread mcameraopenthread ends and merge the threads to determine whether the camera is enabled for exceptions. If yes, send a prompt and click OK to end the activity.

1.5Start the preview thread mcamerapreviewthread. In this thread, the initializecapabilities () method is called. In this method, the default camera parameters are obtained and stored in minitialparams. this parameter is used to call the initializeparameters (minitialparams) method, the initializeparameters method determines whether automatic focus, white balance, or exposure are supported. Obtain the Boolean values of maelocksupported, mawblocksupported, mmeteringareasupported, and mfocusareasupported.

1.5.1 call the startpreview () method to set parameters and start previewing. Call mfocusmanager. resettouchfocus () method, set the seterrorcallback for camera error listening, call setpreviewdisplay (msurfaceholder) method to set the association between camera data and surfaceview. Call setdisplayorientation () to set the preview angle. In this method, obtain mdisplayrotation and obtain mdisplayorientation based on this value.

1.5.2 call setcameraparameters (update_param_all) to obtain and set parameters in all configuration files. The updatecameraparametersinitialize () method is called in the setcameraparameters method. This method obtains all supported preview frames of camera and sets the maximum value of mparameters. setpreviewframerate (max) and set the parameter "video-stabilization" supported by API 14 ". Call the updatecameraparameterszoom () method to set the focal length. The initial value is 0.

1.5.3 call the updatecameraparameterspreference () method to set the parameter settings obtained from mfocusmanager and from the configuration file. Set the focus area and the image size stored in the configuration file. If not, compare all supported dimensions with all sizes defined in the configuration file and set the first matching. Obtain the mpreviewpanel object of the outermost viewgroup class on the preview page. This object is used to determine the width and height of the imageview In the preview Popup. Gets the previewframelayout object to determine the preview ratio ........ Basically, all camera settings are completed in this method.

1.5.4 after calling the setcameraparameters (update_param_all) method, wake up the preview thread and start preview. Call the setcamerastate (idle) method to set the left label and the Enable icon. It is not optional when focusing.

1.6 determine whether a third-party application is called. If not, the modepicker (lower left icon) object is displayed. The initializeindicatorcontrol () method is called to determine the setting part of the interface. In this method, the array setting_keys determines the setting icon (Flashlight, white balance...) displayed horizontally ...), other_setting_keys determines the items in the pop-up setting interface. All settings are defined in the camera_preferences.xml file. Therefore, this method also calls the loadcamerapreferences () method to get mpreferencegroup. The updatescenemodeui () method is called to set the flashlight, white balance, focus mode... whether it can be set (grayed out). null indicates that it can be set, and the condition is whether the scene mode is automatic.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.