Flutter full screen clock! Why do some people say that Android development is no longer popular? Hematemesis

status quo

Backend to Android Where should I start, is it too late to learn Android now?

My answer is that it will not be too late, because the market is now stabilizing and normal. This is the trend of market development. Now it is popular artificial intelligence and big data, just like the mobile development that just started in 2010. At present, the demand is becoming more balanced, and the demand for developers at the junior and intermediate level has decreased, but the market for demand for advanced and above is still very scarce, especially for Android developers in specific segments. Comprehensive capabilities, especially basic principles, are becoming more and more demanding. For example, many companies will give priority to certain requirements, such as the popular Kotlin, hybrid development, cross-platform development, NDK, advanced image processing, etc., the market The popular live broadcasts and small videos on the Internet also have a large demand for senior talents in the audio and video segment, so that AI, AR, VR and other technologies also need to be shown to users through the terminal, so the mobile terminal development will still be in the future. Make a difference.

The interviewer asked a question, let’s take a look at the performance of the three students A, B and C

A

Interviewer: Talk about the role of Application.

A : Application is a system component that will be created after the application process is created, so it can be used to do some initialization operations; Application life cycle is as long as the application process, so it can be used to provide Context to the class library; because all Context can be obtained Application can be used to save and transfer global variables.

Interviewer : Do you usually put global variables in Application? What if the application is recycled in the background and the value is lost when reopened?

A : Yes, it's very convenient, just do a fault tolerance

Interviewer : Okay, go back and wait for the notice


B

Interviewer : talk about the understanding of Application

B : Role: do initialization and provide context. In addition, Application is a Context, which directly inherits ContextWrapper; the member variable mBase of this ContextWrapper can be used to store the ContextImpl implemented by the system, so that when we call the Context method of Application, we will finally call the method of ContextImpl through a static proxy. . We call the getBaseContext method of ContextWrapper to get an instance of ContextImpl

Interviewer : Do you usually put global variables in Application? What if the application is recycled in the background and the value is lost when reopened?

B : No, save global variables with static variables, or singletons can gather them in a more suitable location.
To avoid data loss when the application is recycled, when you can pass parameters on the page, pass the parameters through the Intent, so that it is worthwhile to open and retrieve the parameters from the Intent after being recycled. If the amount of data is large, you can also consider data persistence; another method is to save the corresponding data when it is recycled and restore the data when it is reopened through onSaveInstanceState and onRestoreInstanceState.

Interviewer : Tell me about the life cycle of Application

B : Compared with Activity, the life cycle of Application is not too simple. The constructor is called when it is first created, and then the system is ready to inject the ContextImpl into the Application through the attachBaseContext( Context) method, and then call the onCreate method we are most familiar with. There is also an onTerminate method in the API that will call back when the process is killed, but it only takes effect in the simulator, so you don't need to pay attention.

Interviewer : Can you talk about the initialization process of Application?

B : Basically those mentioned above, I didn’t understand it in detail

Interviewer : Okay, go back and wait for the notice


C

Interviewer : Talk about the initialization process of Application

C : Application is initialized after the application process is created:

ActivityThread calls the attachApplication method of the Binder object (IActivityManager) of
AMS. After receiving the request, AMS calls the bindApplication method of
ActivityThread. ActivityThread This side receives the request and then assembles an AppBindData object, encapsulates all parameters, and sends it to the main thread for execution through the handler

The main thread loops to this message and calls handleBindApplication to actually process the initialization Application

When handleBindApplication talked about "Context", the initialization of Activity was similar. Recap:

ClassLoader loads the Application class, instantiates
the ContextImpl used to initialize the Applicaction
through the Application.attach( Context) method, calls attachBaseContext( Context) to inject the ContextImpl into the Application and
finally calls Application.OnCreate()

Then Application is initialized

Interviewer : Why doesn’t the process creation complete directly call handleBindApplication to create the Application, and then go to AMS to make a circle

C : The attachApplication of AMS is called not only to create the Application, but also the four major components of the application may be called before the process is created but cannot be started; now that the process is created, the application has to be created to process these components to be started. Therefore, unified scheduling is required through AMS. If the application creation and onCreate callback takes time, it will also affect the startup time of these components to be started

Interviewer : Yes, let's talk about other things.

At last

Android learning is a long road. What we have to learn is not only the superficial technology, but also the bottom layer and understand the following principles. Only in this way can we improve our competitiveness. In today's competitive world Foothold in.

Life cannot be smooth sailing. There are peaks and valleys. We must believe that those who cannot defeat us will eventually make us stronger and become our own ferrymen.

I put the most important and popular learning direction materials on Android that I have compiled during this time on my GitHub , which also contains self-learning programming routes in different directions, interview questions/face-to-face, and series of technical articles.

The resources are continuously updated, and everyone is welcome to learn and discuss together.

Guess you like

Origin blog.csdn.net/Sunbuyi/article/details/112901719