The most comprehensive test questions for 2019 BAT Android social recruitment (interview summary + detailed answers!)

Interview: If you don't prepare for a full interview, it will be a waste of time and you will be irresponsible for yourself!

If you want to be excellent, then look at what those excellent people are learning and what they do, and do everything possible to communicate with them; go out and see the world more, and then force yourself to learn to the death.

It is now the peak interview season for Golden 9th and Silver 10th. A large number of graduated and unemployed programmers have entered the intense stage of job interviews. Here I will share my experience in interviews with Android for many years.

This guide is a summary of my experience in interviewing and interviewing others for seven or eight years in development. Most of them are frequently asked interview questions for large companies. You can check this to fill in the vacancies. Of course, the list here is definitely not able to cover all the methods. I hope it will be helpful for everyone to find a job!

At the end of the article, I will share with you the Android interview topics and answers I have compiled. Here are some interview questions:

Note: The answer is at the bottom, because the actual development and the reference answer will be different, and you are afraid of misleading everyone's understanding, so the answers to these interview questions should be understood by yourself! The interviewer will ask questions from the shallower to the deeper on the knowledge points mentioned in the resume, so don't memorize the answers and understand.

Activity basics

  • Talk about the Activity life cycle?
  • What methods will be called when Activity A starts another Activity B? If B is a transparent theme or is it a DialogActivity?
  • Talk about the role of the onSaveInstanceState() method? When will it be called?
  • What are the four startup modes and application scenarios of Activity?
  • Know which flags are commonly used in Activity?
  • Tell me about the relationship between Activity and window, view?
  • Activity life cycle changes when switching between horizontal and vertical screens?
  • How to start the activity of other applications?
  • Activity start process? ( Emphasis )

Fragment basics

  • Talk about the life cycle of Fragment? Is it different from the Activity life cycle?
  • Talk about the difference between Activity and Fragment?
  • The difference between add and replace in Fragment (Fragment overlap)
  • What is the difference between getFragmentManager, getSupportFragmentManager, and getChildFragmentManager?
  • The difference and usage scenarios of FragmentPagerAdapter and FragmentStatePagerAdapter

Service basics

  • Talk about the life cycle of Service?
  • Two ways to start Service? What's the difference?
  • How to ensure that the Service is not killed?
  • Can I start time-consuming operations in Service? How to do it?
  • Which system services have you used?
  • Do you know ActivityManagerService? What role does it play (emphasis)

Broadcast Receiver basics

  • How many forms of broadcasting? What are their characteristics?
  • Two ways to register for broadcasting?
  • Do you understand the principles of broadcast transmission and reception? (Binder mechanism, AMS)

ContentProvider basic related

  • How much does ContentProvider know?
  • ContentProvider permission management?
  • Talk about the relationship between ContentProvider, ContentResolver, ContentObserver?

Data storage related

  • Describe the Android data persistent storage method?
  • Application scenarios of SharedPreferences? Precautions?
  • What is the difference between apply and commit in SharedPrefrences?
  • Do you understand transaction operations in SQLite? How is it done
  • Is there any good way to use SQLite for batch operations?
  • How to delete individual fields of a table in SQLite?
  • What are the optimization operations when using SQLite?

IPC (emphasis)

  • The relationship between process and thread in Android? the difference?
  • How to start multi-process? Can the application start N processes?
  • Why do we need IPC? Possible problems with multi-process communication?
  • The advantages and disadvantages of IPC and various methods in Android, why choose Binder?
  • The role and principle of the Binder mechanism?
  • The role of ServiceManager in the Binder framework?
  • Why does Bundle transfer objects need to be serialized? What is the difference between Serialzable and Parcelable?
  • Talk about AIDL? What is the principle? How to optimize the use of AIDL for multiple modules?

View related

  • Tell me about the drawing process of View?
  • What is MotionEvent? How many events are included? Under what conditions will it occur?
  • Describe the View event delivery and distribution mechanism?
  • How to resolve the event conflict of View? Give an example encountered in development?
  • What is the difference between scrollTo() and scollBy()?
  • How does Scroller realize the elastic sliding of View?
  • What is the difference between invalidate() and postInvalidate()?
  • The difference between SurfaceView and View?
  • How does custom View consider model adaptation?

Handler related

  • Talk about the message mechanism Handler? What? What are the elements? What the process is like?
  • Can a thread create multiple Handlers, and the correspondence between Handler and Looper?
  • The difference between soft references and weak references
  • The cause of memory leak caused by Handler and the best solution
  • Why the system does not recommend accessing the UI in the child thread
  • Why Looper's infinite loop will not cause the application to freeze
  • What will happen to the message queue after using Handler's postDealy?
  • Can a Handler be created directly in the child thread? How to do it?
  • How can Message be created? Which is better? why?

Thread (emphasis) related

  • The benefits of thread pool? Understanding of several parameters of the thread pool, the usage scenarios of the four thread pools
  • What are the classes that facilitate thread switching in Android?
  • Talk about the principle of AsyncTask
  • What is the use of IntentService?
  • The difference between creating a thread directly in Activity and creating a thread in service
  • The working strategy of ThreadPoolExecutor?
  • What is the difference between Handler, Thread and HandlerThread?
  • Principle of ThreadLocal
  • Will multithreading be efficient (pros and cons)
  • In multithreading, let you do a singleton, what would you do
  • In addition to notify, is there any way to wake up the thread
  • What is ANR? Under what circumstances will ANR occur? How to avoid it? How to quickly locate the ANR problem without looking at the code?

Bitmap related

  • What issues should be paid attention to when using Bitmap?
  • Will Bitmap.recycle() be recycled immediately? When will it be recycled? If there is no place to use this Bitmap, why is garbage collection not directly recycled?
  • The memory occupied by a Bitmap and the calculation of memory occupation
  • Cache update strategy in Android?
  • The principle of LRU?

Performance optimization (focus)

  • In the three-level cache of the picture, the picture is loaded into the memory. If the memory is about to burst, what will happen? How to deal with it?
  • If a 500*500 png high-definition picture is loaded in the memory, how much memory should it occupy?
  • Performance optimization of WebView
  • How does Bitmap handle large images, such as a 30M large image, and how to prevent OOM
  • Memory recovery mechanism and GC algorithm (the advantages and disadvantages of various algorithms and application scenarios); GC principle and timing and GC objects
  • The difference between memory leak and memory overflow? What tools does AS have to detect memory leaks
  • Performance optimization, how to ensure that the application startup does not freeze? How to deal with the black and white screen?
  • If a strong reference is set to null, will it be recycled?
  • The difference between ListView and RecyclerView
  • What is the adapter of ListView?
  • LinearLayout, FrameLayout, RelativeLayout performance comparison, why?

JNI related

  • Do you know JNI
  • How to load the NDK library? How to register Native functions in JNI, how many ways are there to register?
  • What function have you implemented with JNI? How did it happen? (Encryption processing, audio-visual aspects, graphics and image processing)

Design pattern related

  • What design patterns do you know?
  • Talking about MVC, MVP and MVVM, what is the good and the bad?
  • After encapsulating the p-layer. If the p-layer data is too large, how to solve it
  • Can you give a few examples from Android to explain what design patterns are used?
  • What is the difference between decoration mode and agency mode?
  • How many ways are there to implement singleton mode? What is the purpose of the double lock in the lazy style? What is the purpose of the two empty arbitrations?
  • Some open source frameworks used, introduce an internal implementation process that has seen the source code.
  • How should Fragment be decoupled if used in Adapter?

Android advanced extension point

  • How to perform unit testing and how to ensure App stability
  • How to check the recycling of an object in Android
  • How to compress the size of APK?
  • How to configure a multi-channel package through Gradle?
  • Analysis of plug-in principle
  • Principle of Formation
  • Cross-component communication
  • Implementation of routing and buried points in componentization
  • Hook and instrumentation technology
  • Android's signature mechanism
  • What is the difference between v3 signature key and v2 and v1
  • What is the big change between Android5.0~10.0?
  • Talk about the Measurepec class
  • Please give examples of common layout types in Android, and briefly describe their usage and typesetting efficiency
  • Distinguish the usage of Animation and Animator and outline the principle
  • What image loading library have you used? How subtle is Glide's source code design?
  • How to bypass the 9.0 restriction?
  • Which network load libraries have you used? The realization principle of OkHttp and Retrofit?
  • How is the application update done? (Grayscale, mandatory update, sub-regional update)
  • Will you use Kotlin and Fultter? Talk about your understanding

Answer

1. Talk about the Activity life cycle?

  • Reference answer : Under normal circumstances, there are only 7 common life cycles of Activity as follows

  • onCreate() : Indicates that the Activity is being created, and is often used to initialize the work, such as calling setContentView to load interface layout resources, initializing the data required by the Activity, etc.;

  • onRestart() : Indicates that the Activity is restarting. Generally, when the current Acitivty changes from invisible to visible again, OnRestart will be called;

  • onStart() : Indicates that the Activity is being started. At this time, the Activity is visible but not in the foreground. It is still in the background and cannot interact with the user;

  • onResume() : Indicates that the Activity gets the focus. At this time, the Activity is visible and in the foreground and starts the activity. This is the difference from onStart;

  • onPause() : Indicates that the Activity is stopping. At this time, you can do some work such as storing data and stopping animation, but it should not be too time-consuming, because this will affect the display of the new Activity. OnPause must be executed first before the onResume of the new Activity carried out;

  • onStop() : Indicates that the Activity is about to stop, and you can do some heavyweight recycling work, such as logging off the broadcast receiver, closing the network connection, etc., and it should not be too time-consuming;

  • onDestroy() : Indicates that the Activity is about to be destroyed. This is the last callback in the Activity's life cycle, often doing recycling and resource release;

  • Extension : From the perspective of the entire life cycle, onCreate and onDestroy are paired, respectively marking the creation and destruction of Activity, and there may only be one call;

  • From whether the Activity is visible, onStart and onStop are paired, and these two methods may be called multiple times;

  • From the perspective of whether Activity is in the foreground, onResume and onPause are paired, and these two methods may be called multiple times;

  • Except for this difference, there is no other obvious difference in actual use;

2. Talk about the life cycle of Fragment?

  • Reference answer:

  • The methods involved in the entire life cycle of Fragment from creation to destruction are: onAttach()→onCreate()→ onCreateView()→onActivityCreated()→onStart()→onResume()→onPause()→onStop()→onDestroyView( )→onDestroy()→onDetach(), among which there are many methods with the same name and similar functions as Activity, and the different methods are:

  • onAttach() : Called when Fragment and Activity are associated;

  • onCreateView() : Called when the fragment creates a view, after onCreate;

  • onActivityCreated() : Called when the Activity associated with the Fragment completes onCreate();

  • onDestroyView() : Called when the layout in Fragment is removed;

  • onDetach() : Called when Fragment and Activity are disassociated;

3. Talk about the life cycle of Service?

  • Reference answer : Service life cycle involves six major methods

  • onCreate() : If the service has not been created, the onCreate() callback will be executed after calling startService(); if the service is already running, calling startService() will not execute the onCreate() method. In other words, onCreate() will only be called when the service is created for the first time, and multiple executions of startService() will not call onCreate() repeatedly. This method is suitable for some initialization work;

  • onStartComand() : Called when the service starts, this method is suitable for completing some data loading tasks, for example, a thread will be created here to download data or play music;

  • onBind() : called when the service is bound;

  • onUnBind() : Called when the service is unbound ;

  • onDestroy() : called when the service stops;

4. How many forms of broadcasting? What are their characteristics?

  • Reference answer:

  • Ordinary broadcast : The broadcast of the intent defined by the developer (the most commonly used). All broadcast receivers will receive the broadcast information at almost the same time, in a random order;

  • Orderly broadcast : The broadcasts sent out are received by broadcast receivers in order. Only one broadcast receiver can receive the broadcast message at the same time. The broadcast will continue after the logic in the broadcast receiver is executed. The broadcast receiver with high priority will receive the broadcast message first. Ordered broadcast can be intercepted by the receiver so that subsequent receivers cannot receive it;

  • Local broadcast : only send and receive broadcasts within your own application, that is, only your own application can receive it, the data is safer and more efficient, but it can only be dynamically registered;

  • Sticky broadcast : This kind of broadcast will remain stuck. When a receiver that matches the broadcast is registered, the receiver will receive this broadcast;

5. How much do you know about ContentProvider?

Reference answer:

As one of the four major components, ContentProvider is mainly responsible for storing and sharing data. Different from file storage, SharedPreferences storage, SQLite database storage, these data storage methods are that the data saved by the latter can only be used by the application, while the former allows data sharing between different applications, and it can also Choose only which part of the data to share, so as to ensure that there is no risk of leakage of private data in the program.

Talk about the recent Android market

Recently I see some cool words from time to time. I always say that Android is cold. I would like to give you a few suggestions. First, you must endure loneliness and not be disturbed by the outside world. Second, you must develop a long-term systematic learning plan and persevere; finally, pay attention to the learning method. , Don’t study casually. Many people only read books and blogs, but never try to practice them. The understanding will certainly not be too deep, and it will be easy to forget over time.

to sum up

Learning technology is a slow, long and arduous road. You cannot rely on a moment of passion, nor can you learn well by staying up for a few days and nights. You must form the habit of studying hard in normal times. So: persistence!

So how can we make good answers in the interview?

The answer, of course, is to improve oneself in work or study.

Moreover, the technical points involved in the interview are not known so much, we need to learn more. In fact, regardless of the size of the interview, if you want to avoid being abused by the interviewer, you have to max out the interview questions and make a comprehensive preparation. Of course, in addition to this, you also need to lay a solid foundation in peacetime. , So no matter how the interviewer digs into his own knowledge, you can cope with it~

Here is a collection of videos about my Android learning interview documents, friends who are interested can take a look~

Finally, I wish you all find a good job and get your favorite offer in the Golden Nine and Silver Ten!

 

Guess you like

Origin blog.csdn.net/weixin_44339238/article/details/102464319