A callback mechanism for the upper layer to obtain the underlying data

Source: Internet
Author: User

Take camera as an example to see how the app gets a picture taken.

The method for taking a photo in the camera class is capture (). It gets response data by inheriting the interface callback function picturecallback In the android. Hardware. Camera class,

This external data is the image data obtained from the underlying layer.

When we press the shutter button, the camera application calls the capture method to enable a camera thread. After the entire camera process is completed at the underlying layer, this thread will send the captured photo data to the camera object through the message mechanism,

The underlying data enters the Java space from the C ++ space and requires an JN layer interface. Here is posteventfromnative ()

Let's move on to the camera local code. We know that the camera system consists of the client T and the server,

The client is our application. The server cameraservice calls the abstraction layer method to obtain the underlying data.

Here, the client obtains the cameraservice: Client: datacallback () data from the camera: datacallback () server,

The code is much more confusing, and the final conclusion is as follows.

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.