Four main components of Android and the MVC Architecture Model, androidmvc
As an Android programmer who has just switched from JAVA, he will always think about what android MVC is like?
First, we must say that Android is pursuing the MVC Architecture, so let's first talk about What MVC is!
In general, MVC cannot be a design pattern. Because the dimension is too large, MVC should belong to the architecture pattern!
Baidu encyclopedia -- full name of MVC is Model View Controller, short for model-view-controller. It is a software design Model, organize the code by separating the business logic and data display, and aggregate the business logic into a component, the interface and user interaction around data can be improved and customized without re-writing the business logic. MVC is uniquely developed to map traditional input, processing, and output functions in a logical graphical user interface structure.
The model layer, view layer, and control layer have their respective responsibilities and are independent of each other. A model can have multiple views, and a view can have multiple controllers, A controller can also have multiple models.
The basic process of MVC is as follows:
The user interacts with the view, and the view accesses and feedbacks the user's action. The view sends the user's request to the corresponding controller, and the Controller determines which model to call, then, the model calls the corresponding business logic to process user requests. If data needs to be returned, the model returns the corresponding data to the Controller, and the Controller calls the corresponding view, in the end, the returned data is formatted and rendered by the view. The returned data can be displayed in a user experience.
Andorid is proud to propose four core components for MVC implementation. I will not discuss them in detail. I would like to give a brief introduction to some of my perceptual knowledge about the four components today:
Activity: Process events related to the UI, present the interface to the user, and respond to the user's request (open an application, all displayed in front of you is Activity. Activity is a container that can carry its control !);
Service: backend Service, which is generally used for time-consuming operations. It runs on the backend and for a long time! Service is a behind-the-scenes worker. Although you cannot see the process of the officer, you can see the final result. Although the Service is working behind the scenes, it is not costly, and the system overhead is also a lot );
BoadcastReceiver: receives a broadcast event and processes the event's click. For example, when you receive a text message, the system will find that the message is sent, the BoadcastReceiver that can process the broadcast will be processed as needed (broadcast, everyone knows this channel !);
ContentProvider: stores and processes data and provides consistent external processing interfaces;
I wrote a story about four Android components to share with you:
I went to McDonald's for a meal and saw McDonald's logo and noodle shop decoration before entering the door.
Entering the store, decorating the layout, table and chair tableware, and waiters all adopt the McDonald's style. Both the reception and the communication terms are the same, with the standard McDonald's model. (Now, everything in front of me is Activity ).
After a few minutes, I waited. However, I picked up the latest advertisement and received another call. After a while, I ordered something. I picked up and sent a microblog and a circle of friends. I didn't care about the busy kitchen and food manufacturing process (this is the Service)
After a while, the broadcast in the store informed the customer to go to the front desk to fetch the hamburger and fries which had already been prepared. Then a man around me got up and went to the front desk. (This is BoadcastReceiver)
After dinner, I threw the printed receipt at the order into the garbage bin at the door (the receipt is ContentProvider )!