preface
I do not know how long you have not participated in the interview, recently this period of time of the interview, is really a strict than a!
Yesterday, I participated in the technical side of a big factory. I was scared to die on the spot. I didn’t expect it to be so difficult!
For the first time to read dry goods, you can pay attention to my public number: program ape cultivation center
If you don’t believe me, you too die die:
- Draw the big picture of Android
- Describe what happens when you click on the Build button in Android Studio, outlining what happens when an application is installed on the phone;
- Basic understanding of Dalvik and ART virtual machine;
- How inter-process-Communication works on Android;
- How and why apps are sandboxed;
- Permissions management system (how the underlying permissions are granted)
- Process and Application lifecycle;
- List inversion
- Dynamic permission adaptation scheme, concept of permission group
- How does OKHTTP handle network caching
You call this interviewer tough or not! Too hard!
For us programmers, the interview is about presenting our skills to the interviewer. When I was looking for a job at school, I found that the first person to get a job was not the most skilled but the one with high communication skills. The most common complaint I heard was “why do I know this but I don’t know where to start in the interview”.
Based on my own experience, this paper will talk about how to make full preparations before the interview, how to fluently express my skills, and how to be calm and calm when entering the project from being confused and blind at the beginning.
Interview preparation
Here I will share the preparation before the interview from the following aspects.
1, to position themselves first to position themselves, they are now a stage, is the primary post, senior, senior, or expert level. Under normal circumstances, just work for a year or so when the primary, two years or so to improve their words is intermediate, three to five years senior or even expert level. The premise is to keep studying.
2. Comb the knowledge because I position myself as a senior development engineer, as the saying goes: interview repair aircraft carrier, work screw. The interview considers all aspects, for Android, there are mainly the following aspects to prepare: Java foundation, Android foundation, Java concurrency, Java virtual machine, Android source code (including framework and open source projects), data structure and algorithm. Of course, after combing the basic knowledge, but also to read some interview, see the latest questions asked by each manufacturer. In fact, these things are ready, a good foundation, about a month, the foundation is not good at least 3 months.
As the saying goes, don’t fight a battle unprepared. Only when you are prepared can you achieve good results in the interview process.
3, resume preparation
Resumes are a stepping stone, and HR gets a lot of them every day. How to make a CV stand out and capture key information at a glance: personal details (name, phone number, email, university, etc.), work experience, skills, highlights (cet 6, awards, etc.). Keep your resume simple and structured. After writing your resume, update it on the recruitment website.
4. Various channels of interview opportunities This interview has been through three channels, one is the recommendation of friends, the other is the help of headhunters, and the third is the boss or Zhaopin.
- Friend push: in the circle first to know some friends, the employees of various manufacturers, you can add friends through pulse, also can add friends through technical exchanges, understand the dynamics of friends, let them help recommend. Of course, there are two ways to find extrapolation. The first is to ask a friend for a recommendation and ask if there is a vacancy in the group. The second way is to find the job by yourself. Under normal circumstances, the company’s job fair will display the link to join us on its official website, where you can see the job information. The second way is to find the position yourself, send it to a friend and ask him to recommend it directly. Referrals are usually rewarded.
- Headhunter’s help: I recently listened to a course “How to effectively improve the competitiveness of the workplace”, and I think the teacher said a very good sentence, do not exclude headhunters, take headhunters as your partner. The recruiter knows more about the company and what’s going on than you do. There are also many ways to find headhunters. The first is to ask your friends whether they have cooperated with reliable headhunters. The second is that there are many headhunters on zhaopin.com, Liepin and Boss Zhippin. After you update your resume, a headhunter will contact you.
- Recruitment website: Internet recruitment is on the hook, boss, intelligent. Resume updated to the website, and then can be delivered, here to see whether the resume delivery effect, if half a day no one to view your resume, so that your resume has a problem, timely modification and re-delivery.
5. Skill reserve
- One or two years after graduation:
Java basic knowledge needs to master: object-oriented understanding, basic types and reference types, constructors, common classes (inner class, anonymous class, abstract class), three features (encapsulation, inheritance, polymorphism), rewriting and overloading, interface and interface implementation, and so on. The interviewer will ask you these questions on a mastery level, mainly to see if your basic knowledge is solid, after all, Android is written in Java.
Android: The simple use of four components, the life cycle of activity, fragment binding, value transfer between activity and fragment, RecyclerView realization list of nine grid waterfall flow layout, viewHolder The reuse problem, the characteristics of several ways of data storage, the use of common framework Glide, Retrofit, eventBus, Butterknife.
- Two to three years after graduation:
For android programmers who are two or three years old, Java isn’t just about using the basics, it’s about understanding them as they go along. For example, encapsulation, the interviewer will not ask you what encapsulation is, but rather what code/features you have encapsulated in your company and how you did it. This time to check is whether you can write code or just imitate code, if you do not have their own package code in the project you can read the source code of some excellent frameworks online to learn how others are packaged.
Of course, there are a lot of things to learn from encapsulation, such as Java generics, reflection, collection frameworks, interfaces and abstract classes, design patterns, and more. Master these in addition to watching video learning can also read some excellent source code. If you don’t understand something, check the blog again. After you understand it thoroughly, be sure to apply it to your own project, so that you can be impressed by the learning and the interviewer can ask for a list of examples.
Android: APP startup principle, If you want to know more about chat (APP startup principle and startup optimization details), picture compression and performance optimization, custom view, event distribution process, screen adaptation, component and plug-in, Glide cache and reuse, OkHttp Responsibility chains and connection pools, serialization and deserialization, analyzing the source code of one of your most familiar frameworks, and more. As you can see, for two or three years of programmers, not only master more knowledge, but also need to have a certain understanding of the principles.
Interview experience sharing, the difference between large and small factories
Big factory interview experience
When I first went out to find a job, I interviewed many companies. At that time, it was the explosion period of mobile development, including medium and large companies such as Tencent and some small companies that just started their own business. Of course, the big companies failed in the interview. I remember when I went to Tencent for an interview, there were so many people going to the interview that I had to wait in the hall for the interview in batches. After the group interview, I knew the basic information, and then I had a separate interview to wait for the interview. There were three rounds of interviews in total, and the interviewer would inform the time of the interview results.
Questions mentioned by the interviewer include: why did you leave your last job, how do you view our company, what is your career plan in the future, and how to optimize the startup optimization in terms of technology? How to pass large memory data across processes? How can the main thread wait for all threads to complete and then execute a particular task? Principle and source code read? How do you implement rxPay and rxLogin?
The difference between big and small factories
- Giant:
Process is more, tend to have more than three sides, first of all, will have a set of interview questions waiting for you, of course, not all companies have the interview questions, but companies have higher probability of interview questions and the second technology is in charge of the interview, then technical manager interview, hr would like you to meet the development of the company business corporate welfare work time and so on. Big factory development is generally divided into modules, each person is responsible for a module, so it requires you to have their own advantages, such as you can write custom components, video modules, NDK deep research and so on.
- The small factory:
Less process, you may be called to work after one. Small company interview must ask clear wages when hair, hair at the beginning of the company’s sufficient funds, mid-month hair is normal, if only at the end of the company’s financial strain is likely to appear in a financial crisis. Still have 5 insurances 1 gold, have if probation period, still have a part company to do not have 5 insurances 1 gold at present, and probation period of major company does not hand in 5 insurances 1 gold. About the importance of 5 insurance one gold everybody can go baidu search, after limit purchase makes come out this is more important.
The technical difference is that small companies tend to be one-person development, requiring you to know the entire development process of a project, but not requiring much technical depth (for junior programmers only, senior architects are another word). Before the interview, prepare more projects to demonstrate, some people say that those who understand technology do not see the work, but for small companies, it is different, you may be interviewed by product managers, background personnel and so on, the understanding of Android is not very deep, at this time there are a few good work demonstration will give you a lot of points in the interview.
Android interview questions often asked knowledge analysis
The following five questions are typical questions that I have been asked in interviews, and that interviewers have asked others.
How activities communicate with each other
1) Pass a parameter jump through an Intent
2) Broadcast
3) Callback through the interface
4) Use static or global variables of the class
5) Use SharedPreference or external storage, such as databases or local files
Please introduce the data storage mode of Android
Store data using SharedPreferences; File storage data; SQLite database stores data; Use ContentProvider to store data; Networks store data.
Preference, the File, /data/data/Package Name/Shared_Pref, /data/data/Package Name/files, / data/data/Package Name/database.
- Use SharedPreferences to store data
The SharedPreferences store is a mechanism provided by Android to store some simple configuration information, such as the user name and password of the logged-in user. It uses Map data structure to store data in the form of key values, which can be read and written simply. Specific examples are as follows:
void ReadSharedPreferences(){String strName,strPassword; SharedPreferences user = getSharedPreferences (" user_info ", 0); StrName = user. Get string (" NAME ", ""); StrPassword = user get string (" PASSWORD ", ""); }void WriteSharedPreferences(String strName,String strPassword){SharedPreferences user = GetSharedPreferences (" user_info ", 0); uer.edit(); User. PutString (" NAME ", strName); User. PutString (" PASSWORD ", strPassword); user.commit(); }Copy the code
Data is read and written in very simple ways, with some differences at write time: edit() is called before the data is modified, and commit() is used to commit the modified data. In fact, SharedPreferences uses XML format to store data to the device under /data/data//shares_prefs in the File Explorer in DDMS. Using SharedPreferences is somewhat limited: it can only be used within a package, not between packages.
- File storage data
File storage is a common method. The method of reading/writing files in Android is exactly the same as that of implementing I/O programs in Java. OpenFileInput () and openFileOutput() methods are provided to read files on the device. Specific examples are as follows:
String fn = "moandroid. Log"; FileInputStream fis = openFileInput(fn); FileOutputStream fos = openFileOutput(fn,Context.MODE_PRIVATE);Copy the code
- Network storage data
Network storage mode, need to deal with the Android network package, for details about the Android network package, please read the Android SDK reference Java SDK package? .
What are the startup modes of the activity? What does it mean?
In Android, there are four startup modes for activities:
-
“Standard” (default)
-
“SingleTop”
-
“SingleTask”
-
“SingleInstance”
The main differences are as follows:
- How do I decide to belong to a Task
The target task for “standard” and “singleTop” activities is in the same task as the sender of the incoming Intent, unless the Intent includes the FLAG_ACTIVITY_NEW_TASK parameter. If FLAG_ACTIVITY_NEW_TASK is provided, it will be started in another task. “SingleTask” and “singleInstance” always have the activity as the root element of a task, and they will not be launched into another task.
- Whether multiple instances are allowed
“Standard” and “singleTop” can be instantiated multiple times and exist in different tasks, anda task can contain multiple instances of an activity. “SingleTask” and “singleInstance” limit the generation of only one instance, which is the root element of the task. SingleTop requires that if an intent is created with an instance of the Activity to be created already at the top of the stack, then the intent is sent to that instance, not to the new instance.
- Whether to allow other activities in this task
“SingleInstance” monopolize a task, and other activities cannot exist in that task. If it starts a new activity, regardless of the launch mode of the new activity, the new activity will be run in another task (as in FLAG_ACTIVITY_NEW_TASK).
The other three modes can coexist with other activities.
- Whether a new instance is generated each time
Standard generates a new instance of an activity for each launched Intent.
If the activity of “singleTop” is at the top of the stack, the new instance of the activity is not generated. If the activity is at the top of the stack, the instance of the activity is generated.
For example, if the task element is a-B-C-D (with D at the top of the stack), issue A launch intent to D. If D is “standard”, A new instance of D is generated and the stack changes to A-B-C-D-D.
If D is singleTop, no new instance of D is produced and the stack state remains a-B-C-D.
If an Intent is issued to B, A new instance of B will be created regardless of whether B’s launchmode is “Standard” or “singleTop”, and the stack state will change to A-B-C-D-B.
“SingleInstance” is the only activity on its stack, and it is reused every time.
If the “singleTask” is at the top of the stack, the intent is accepted; otherwise, the intent is discarded, but the task is returned to the foreground.
When an existing activity instance handles a new intent, the onNewIntent() method is called. If an activity instance is generated, the user can use the back key to return to the previous state. If an existing activity handles the intent, the user cannot return to the previous state by pressing the back key.
Talk about the relationship between ContentProvider, ContentResolver, and ContentObserver
ContentProvider is used to share data between applications and provide content to other applications. If the Contact application uses ContentProvider, you can read and modify contact information in your application, but you need to obtain the corresponding permissions. It is also just middleware, the real data source is a file or SQLite etc. ContentResolver content parsing, data is used to obtain the content provider, through ContentResolver. NotifyChange (uri) issued a message listener ContentObserver content, can be monitored data change state, Observing database changes caused by specific URIs, and then doing some processing accordingly, is similar to a database trigger that is triggered when the Uri observed by ContentObserver changes.
There are several ways to register for broadcast. What are the advantages and disadvantages of these ways? Talk about why Android introduced broadcasting.
Start by writing a class that extends from BroadcastReceiver
First: declare in the manifest file and add
The second uses code for registration such as
The differences between the two types of registration are:
- The first is not resident broadcasting, that is, broadcasting follows the life cycle of the program.
- The second type is resident, which means that when the application is closed, it will be automatically run by system calls if there is a message broadcast.
Current mainstream framework sharing, how to quickly start the project
Build the main frameset of the project
Dagger2+RxJava+Retrofit+MVP is the framework set I am currently using, which is widely used at present. The combination of the four forms a beautiful overall architecture of the project. Package to import
> dependencies {/ / network request the compile 'com. Squareup. Retrofit2: retrofit: 2.1.0' compile 'com. Squareup. Retrofit2: adapter - rxJava: 2.0.1' compile 'com. Squareup. Retrofit2: converter - gson: 2.0.0 - beta4' compile 'com. Squareup. Retrofit2: converter - scalars: 2.0.0 - beta4' compile 'com. Squareup. Okhttp3: okhttp: 3.2.0 "/ / comment the compile 'com. Google. Dagger: a dagger: 2.0.2' apt 'com. Google. Dagger: a dagger - compiler: 2.0.2' provided 'org. Anyone: javax.mail. Annotation: 10.0 - b28' compile 'com. Jakewharton: butterknife: 7.0.1 / / Rx compile 'the IO. Reactivex: rxandroid: 1.1.0' compile 'IO. Reactivex: rxJava: 1.1.5'}Copy the code
Below is the MVP architecture diagram
The View does not interact directly with the Model, but uses a Presenter as a bridge between the View and the Model.
The Presenter layer refers to both the View layer and the Model layer Interface. The View layer refers to the Presenter Interface. When a View layer interface needs to present some data, it first calls an interface of the Presenter layer, which then calls the Model layer to request the data.
When the Model layer data is loaded successfully, the Presenter layer callback method is called to notify the Presenter layer that the data is loaded successfully.
Finally, the Presenter layer calls the View layer interface to present the loaded data to the user. This is the whole core process of MVP mode. If you are interviewing for a junior Android developer, the interviewer will probably only ask you to explain the whole process, as long as you can speak the whole process smoothly.
## Flowchart of Dagger2
What is a Dagger2
Dagger2 is a dependency injection framework, as is Butterknife. The butterknife, however, is called a cream knife at best, while the Dagger2 is called a sharp knife. Its main function is object management, which aims to reduce program coupling.
The advantages of Dagger2
- Simple access to global object instances
Just as the ButterKnife library defines views, event handling, and resource references, Dagger2 provides easy access to global object references. Instances that declare singletons are accessible using @inject. Here’s an example of MyTwitterApiClient and SharedPreferences:
> public class MainActivity extends Activity { @Inject MyTwitterApiClient mTwitterApiClient; @Inject SharedPreferences sharedPreferences; public void onCreate(Bundle savedInstance) { // assign singleton instances to fields InjectorClass.inject(this); }
Copy the code
- Complex dependencies require only simple configuration
Dagger2 uses dependencies and generates code that is easy to understand and analyze. Object references from previously handwritten template code will be created for you by it and passed to the corresponding object. So you can pay more attention to what is built in a module than to the order in which object instances are created in a module.
- Make unit testing and integration testing easier
Because the dependencies have been isolated for us, we can easily extract different modules for testing. The injection and configuration of dependencies are independent of the component. Because objects are initialized in a separate, uncoupled place, when injecting abstract methods, we only need to change the implementation method of the object rather than overhaul the code base. Dependencies can be injected into a component: we can inject mock implementations of these dependencies, which makes testing easier.
- Scoped Instances
Not only can we easily manage global instance objects, but we can also use scope in Dagger2 to define different scopes. (for example, based on the user session, activity lifecycle)
- What is a Retrofit
Retrofit is a REST client library for Android and Java developed by Square. This library is very simple and has many features, compared to other web libraries, easier for beginners to learn quickly.
- How do I create Retrofit instances
Creating an instance of Retrofit requires setting the URL through retrofit.Builder and calling the baseUrl method.
The interface definition
Take the example of getting a list of times
> public interface TimeService {> @GET("getTimes?" ) Call< ResponseBody > getTimes (@Query("month") String month); }Copy the code
Note that this is interface, not class, so we can’t call this method directly. We need to create a TimeService proxy object using Retrofit.
TimeService timeService= createRetrofit().create(TimeService .class);
Interface call
> Call<ResponseBody> mService= timeService.getTimes ("1"); mService.enqueue(new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { try { Log(response.body().string()); } catch (IOException e) { e.printStackTrace(); } } @Override public void onFailure(Call<ResponseBody> call, Throwable t) { t.printStackTrace(); }});Copy the code
How to quickly understand the project for secondary development
When we enter a new company to work, we may take over not a new project but the maintenance of other people’s development of the project, facing the huge project do not know where to start. What I want to tell you here is that when you get a project, don’t blindly develop it but read the source code of the project. To read the source code, first browse the project structure,
From this structure diagram, we can know that the project uses MVP architecture. There are two lib, one related to service and one related to image processing. Then read the build.gradle file, which contains the reference address of the third party library used in the project, and know which technology is used in the project. If there is a third party library that you are not familiar with, you can search for resources according to this address to get familiar with the call method of the module used in the project, and gradually study the source code and implementation principle of the library in the future. When you know more about these, take a look at the requirements document and design diagram, walk through the process according to the requirements, mainly record the jump between activities, you can draw a structure diagram of the jump between classes, so that the whole jump logic will be clearer.
Two more things worth reading are the utility classes in the project and the packaged components. I believe many people have encountered, looking for a long time on the Internet to process data method, after many days found that the project tool class can be directly used. Packaged components are similar to tools that can be used directly, and later development advocates componentization of projects.
The last
Because the level is limited, have wrong place unavoidable, rather misdirect others, welcome big guy to point out! Code word is not easy, thank you for your attention!
🙏 If you are studying with me, you can follow my official account — ❤️ Program ape Development Center ❤️. Every week, we will share the technology of Android regularly.