If you make a frame diagram, it is like this: this is just a simple frame diagram, but there are actually many branches.
Many large companies will have many technical interview questions during the interview, which is an essential topic for programmers.
For example:
What are the ways of multi-process communication in 1.Android?
2. What do you use for process communication? What is the principle? (ByteDance, Xiaomi)
3. Describe the principle of binder mechanism? (Oriental headlines)
What is the workflow of 4.4? Binder thread pool (Oriental headlines)
How did 5.5 do it? Handlers communicate with threads? What is the principle? (Oriental headlines)
6.Handler If there is no message processing, is it blocking or non-blocking? (ByteDance, Xiaomi)
7. how is handler.post (runnable) runnable executed? (ByteDance, Xiaomi)
8.handler's callback and handlemessage exist, but will the callback return true handleMessage? (ByteDance, Xiaomi)
9. What's the difference between 9.sendMessage and postDelay of 9? Handler? (ByteDance)
What is 10? IdleHandler? How to use it? What problems can it solve?
1 1.Looper.loop Why not block the main thread? (Tencent)
12.Looper infinite loop Why is there no ANR?
13. How to create a looper in a child thread? (ByteDance, Xiaomi)
14. The relationship between bending needle, processor and line. For example, how many loopers can a line have and how many processors can it correspond to? (ByteDance, Xiaomi)
15. How to update the UI? Why can't a child thread update the UI? (Mei Tuan)
16 principle. ThreadLocal and its application in Looper? (ByteDance, Xiaomi)
17. How does Android store data?
18.SharedPreference principle, what is the difference between commit and apply? What should I pay attention to when using? (Tencent)
19. How to judge whether an APP is the foreground or the background?
20. How to keep the application alive?
2 1. What is the size of a picture 100x 100 in memory? (ByteDance)
22. What kind of parameters can be transmitted by the principle and function of intention?
Then it will expand to the deeper knowledge details related to these knowledge points until you can't answer them, so as to explore your technical margin and gain a deeper understanding of your technical ability.
The importance of Android framework
Although the development of Android framework is relatively low-level and narrow-minded, things that can master some principles can be bypassed by analogy and developed to the application layer. Next, let's take a look at how important framework knowledge is. Give a few chestnuts, and you may understand.
For example, frame dropping monitoring, function instrumentation, slow function detection, ANR monitoring and startup monitoring, you need to have a deep understanding of the framework to know how to monitor, what mechanism to monitor, where to insert function instrumentation, which class, which method and which attribute to call to reflect. ...
At present, the development of app in large companies should be based on the ideas of modularization, layering, componentization and control, which are all based on the realization of the underlying principles of the Android Framework system framework.
Binder is the most important component of Android system.
What is an adhesive? Please look at the picture below, which is the clearest and most intuitive expression tool.
Advantage description
Performance: Only one data copy is needed, which is second only to * * * memory in performance.
Stability: Based on C/S architecture, with clear responsibilities, clear architecture and good stability.
Security: Assign a UID to each App, and the UID of the process is an important symbol to identify the process.
Android IPC Binder mechanism includes: Linux preparation knowledge, traditional IPC communication principle in Linux, Binder IPC communication principle, and Binder Java layer implementation. These have many small branches, and small details need to be carefully studied and mastered.
Interview with Binder, Senior Engineer of Tencent
1.why does Android use Binder as IPC mechanism?
2. What exactly is 2? A binder?
How about 3.3? Binder mechanism across processes?
4. What is the basic flow of binder communication?
5. Why do objects passed between activities need to be serialized?
6. What is the communication mechanism at the bottom of the four components?
What is the internal implementation principle of 7.7? AIDL?
These are all questions about the binder mechanism that will be asked in the interview.
Handler is mainly used for asynchronous message processing: similar to auxiliary classes, it encapsulates interfaces such as message passing and message processing. When a message is sent, it first enters a message queue, and the function of sending the message returns immediately, while the other part takes out the messages one by one in the message queue, and then processes the messages, that is, the sending and receiving messages are asynchronous. This mechanism is usually used to handle relatively time-consuming operations.
2. Why use handler?
Why use handler? Can we not use this mechanism? No way! When android was designed, it encapsulated a set of message creation, transmission and processing mechanisms. If you don't follow this mechanism, there is no way to update UI information, and an exception message will be thrown.
In the development of android, some operations are often carried out in sub-threads. When the operation is completed, some data will be sent to the main thread through the handler to inform the main thread to do the corresponding operation. Explore the principle behind it: the main thread of the sub-thread handler actually constitutes the classic problem producer-consumer model in the thread model. Producer-consumer model: producers and consumers use the same storage space at the same time, producers add data to storage space, and consumers take data from storage space.