android Summary of advanced interview questions
Heroes, The year-end job hopping craze is about to start, You want to jump to a better one, A company with a higher salary? Be able to answer the following questions in detail, Then you have no distance from a high salary. Announce the answer in the evening!!!
1.android What is the memory leak? How to deal with it??
answer： The main reason for the memory leak is that the developer did not release the static variables or the system service resources in time after using them, which led to the memory leak. Multiple memory leaks can also cause memory overflows.
2. What is the process of message processing mechanism?
answer： Message processing mechanism in literal sense, NamelyAndroid This mechanism is used for message delivery in development. Mainly used inUI Threads and sub threads, Message passing between child threads. It contains three concepts,Handler,Looper,MessageQueue. What are their respective functions, FirstMessageQueue Is a message queue, It's a linked list structure, Following the principle of first in, first out,Android Pass throughMessage Object send message toMessageQueue in.Looper It's a messaging vehicle, It plays the role of, TransportMessageQueue tohandle To process.Handle Is a platform for receiving and processing messages, It receives the message and processes it.
3. What is a custom component, What did you use in the project?
answer： There are three types of custom components, They are combination components, Inheritance component, Self drawn component.
In the project, Composite components are very common, MajorityApp It will be customizedtitle, Onetitle Search in, Return key, Caption text. This is a composite component;
Inherit components, Mainly in the case that the original system control does not meet the requirements, Used to expand its functions. such asexctend
LinearLayout,ListView,AutoCompleteTextview etc. RealizationOnMeasure,onDraw.
Self drawn component, Mainly in graphics and images, Like drawing a pie chart, Dashboard. Mainlyexctend View RealizationonDraw Method, Drawing from coordinate points.
4.activity Life cycle of
answer： NaturalActivity The life cycle of：onCreate,onStart,onResume,onStop,onDestory
1:A Page skipB page, Then?finish B A The life cycle is：onPaused,onStop;onRestart,onResume
2: Be inA Page clickhome key A life cycle：onPaused,onStop
5. Four startup modes, What's the difference?
answer： The first four startup modes are standard,singleTask,singleTop,singleInstance.
standard： Standard start mode, AlsoAndroid Default startup mode.
singleTop： If the mode is set, CurrentAcitivity If there is a task stack top, You do not need to create a newactivity;
If the mode is set, CurrentAcitivity If it exists in the task stack, You do not need to create a newactivity Example, And take this.activity Example above, Through the stack;
singleInstance： If the mode is set, CurrentAcitivity If there is any task stack in the application, You do not need to create a newactivity;
6. What frameworks are used in the project? And how well?
answer：okhttp,imageLoader,zxing,xutils,pushSDK, GouldSdk, BaiduFaceSDK
7.android Internal process of event distribution mechanism in? Detailed explanationrecyclerView purpose
answer：Android The event distribution mechanism of is that the user creates a click event, The system will distribute the event to each layer layout. There are three levels of layout, Namely
activity layer---->viewGroup layer---->view layer, Each layer has an implementationdispatchTouchEvent,onTouchEvent
Method. Event distribution is to pass events through the top-down mechanism first. If thedispatchTouchEvent Method to process the lastreturn
true Words, Then the event will be consumed by this layer, Will not continue to pass down. Ifreturn false, Time continues to pass down toView layer, And eventuallyview Of
onTouchEvent consumption, And then pass it to each layer in a bottom-up wayonTouchEvent Method, Finally, an event handling result is passed to the user.
recyclerView Actually, it is.ListView andGridView Upgraded version. It exists inAndroid L
support.v7 In bag. AndListView Comparison added slide delete, Implementation of drag and drop, And automatic data refresh. Developers just need to implementItemTouchHelper The corresponding sliding deletion and dragging methods in inner class methods can receive their callbacks. Note the need andrecyclerView Binding.i
8. What design patterns do you often use or encounter in the project, For example, And talk about the characteristics.
answer： Common design patterns include builder pattern, Singleton mode, Factory mode, Archetypal model, Adapter mode.
For more information, please refer to here http://blog.csdn.net/ruizhenggang/article/details/78837183
9. How to scroll and play custom lyrics?
answer： There are two ways to implement custom lyrics. One isTextview How to cover, Highlight lyrics in play; One is to usedrawtext How to draw lyrics.
First, the program will read the lyrics file in the directory, Stored in the corresponding object, Including the playing time and duration of each Lyric; Then get the total duration of the corresponding audio file. Through simple mathematical calculation, Then start two threads respectively, Playing music and executing lyrics. Text displayed on the page if the corresponding lyrics are broadcast, Overlay with highlighted text. This is a simple Lyric play function. Another is throughdrawText mode, Draw the lyrics in different colors.
10. The principle of implementing custom line chart and custom gesture password?
11. Which layouts are commonly used in a project, How is screen adaptation done?
answer： Common layouts areLinearLayout,realativeLayout,FrameLayout. Use screen adaptation as much as possiblelinearLayout To do. Or you can use percentage adaptation.
12. Describe in detailAscynTask What's this?
13.android Four components of, And how components interact with each other? What is the storage of data?
answer： The four components are activity,Service,contentProvider,broadcastReceiver
adoptIntent To make mutual calls.
Data storage has：sharedPerfence,fileOutStream,SDCard,DButils,http storage.
14.android inlistView How to delete left slide? Then how does it avoid the conflict between the left slide event and the up slide event?
15.android Of one of the pictureslist, Achieve click picture, Expand aactivity, Implementation plan.
16.handler in, If multiple messages are sent continuously, And sleep for two seconds after the first message is sent, Article 2 sleep5 second, Article 3 normal transmission, What is the order of execution?
17. What system components or functions have you used?
18. aboutluncherMode Know how much?
19.service Use,startService andbindService What's the difference??
20. Know aboutboradCastReceiver Priority of?
21. Obtainandroid Root layout, as well asrootview Under allbutton, And set the color?
22.service Open child threads andActivity Enable child thread comparison in
23.bitmap Where is the cache of? How to get?
24.activity How to transfer data toFragment?Fragment How to transfer data toActivity?
25. performance optimization, How to make sure the application doesn't get stuck