android Summary of advanced interview questions
Great Xia , 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 , namely Android This mechanism is used for message delivery in development . Mainly used in UI Threads and sub threads , Message passing between child threads . It contains three concepts ,Handler,Looper,MessageQueue. What are their respective functions , first MessageQueue Is a message queue , It's a linked list structure , Following the principle of first in, first out ,Android Medium pass Message Object send message to MessageQueue in .Looper It's a messaging vehicle , It plays the role of , transport MessageQueue to handle To deal with .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 , Inherited components , Self drawing components .
In the project , Composite components are very common , majority App It will be customized title, One title Search in , Return key , Title 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 as exctend
LinearLayout,ListView,AutoCompleteTextview etc. , realization OnMeasure,onDraw.
Self drawing components , Mainly in graphics and images , Like drawing a pie chart , Dashboard . Mainly exctend View realization onDraw method , Drawing from coordinate points .
4.activity Life cycle of
answer ： natural Activity The life cycle of ：onCreate,onStart,onResume,onStop,onDestory
1:A Page skip B page , then finish B A The life cycle is ：onPaused,onStop;onRestart,onResume
2: be in A Page press home 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 , It's also Android Default startup mode .
singleTop： If the mode is set , Current Acitivity If there is a task stack top , You do not need to create a new activity;
If the mode is set , Current Acitivity If it exists in the task stack , You do not need to create a new activity example , And put this activity Example above , Open stack ;
singleInstance： If the mode is set , Current Acitivity If there is any task stack in the application , You do not need to create a new activity;
6. What frameworks are used in the project ? And how well ?
answer ：okhttp,imageLoader,zxing,xutils,pushSDK, Gaud Sdk, Baidu FaceSDK
7.android Internal process of event distribution mechanism in ? Detailed explanation recyclerView purpose
answer ：Android The event distribution mechanism of is that users create 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 implementation dispatchTouchEvent,onTouchEvent
Method of . Event distribution is to pass events through the top-down mechanism first . If the dispatchTouchEvent Method to process the last return
true The words , Then the event will be consumed by this layer , Will not continue to pass down . If return false, Time continues to pass down to View layer , And eventually view Of
onTouchEvent consumption , And then pass it to each layer in a bottom-up way onTouchEvent method , Finally, an event handling result is passed to the user .
recyclerView It's actually ListView and GridView Upgraded version of . It exists in Android L
support.v7 In bag . And ListView Comparison added slide delete , Implementation of drag and drop , And automatic data refresh . Developers just need to implement ItemTouchHelper The corresponding sliding deletion and dragging methods in inner class methods can receive their callbacks . Note the need and recyclerView 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 , Prototype mode , 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 is Textview How to cover , Highlight lyrics in play ; One is to use drawtext 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 through drawText 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 are LinearLayout,realativeLayout,FrameLayout. Use screen adaptation as much as possible linearLayout To do it . Or you can use percentage adaptation .
12. Describe in detail AscynTask What is it? ?
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
adopt Intent To make mutual calls .
Data storage has ：sharedPerfence,fileOutStream,SDCard,DButils,http storage .
14.android in listView 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 pictures list, Achieve click picture , Expand a activity, Implementation plan .
16.handler in , If multiple messages are sent continuously , And sleep for two seconds after the first message is sent , Article 2 sleep 5 second , Article 3 normal transmission , What is the order of execution ?
17. What system components or functions have you used ?
18. about luncherMode How much do you know ?
19.service Use of ,startService and bindService What's the difference? ?
20. Have an understanding boradCastReceiver Priority of ?
21. obtain android Root layout , as well as rootview All of them button, And set the color ?
22.service Open child threads and Activity Enable child thread comparison in
23.bitmap Where is the cache of ? How to get ?
24.activity How to transfer data to Fragment?Fragment How to transfer data to Activity?
25. performance optimization , How to make sure the application doesn't get stuck