2023 Android interviewers frequently asked questions and answers (with the latest 174 questions that must be taken by major Android interview companies)

foreword

It's already 2023, but the cold winter of computers has not yet passed, but the enthusiasm of our programmers will not be wiped out (the more money you have, the more powerful you are). In this season of gold, silver and silver, many companies have also released more job interview opportunities, so we have to seize them. Here are some interview questions to share with you, hoping to help you find a good job.

1. What is symmetric encryption and asymmetric encryption in the way Android interacts with the server

Symmetric encryption means that the same key is used to encrypt and decrypt data. The algorithm in this area is DES.
Asymmetric encryption uses different keys for encryption and decryption. Before sending data, you must first agree with the server to generate a public key and a private key. Data encrypted with the public key can be decrypted with the private key, and vice versa. The algorithm in this area is RSA. Both ssh and ssl are typical asymmetric encryption.

2. What are the two ways for Android to start Service? What are their applications?
If the background service can basically run independently after starting, you can use startService. The music player can be used in this way. They will run until you call stopSelf or stopService. You can communicate with a running background service by sending Intents or receiving Intents, but most of the time, you just start the service and let it run independently. If you need to communicate more frequently with the background service through a persistent connection, it is recommended to use bind(). For example, you need the location service to continuously pass the updated geographic location to the UI. Binder is more complicated to develop than Intent, but you can only use it if you really need it.
startService: The life cycle is different from the caller. If the caller exits directly without calling stopService after startup, the Service will still run
bindService: the life cycle is bound to the caller, once the caller exits, the Service will call unBind->onDestroy

3. Tell me about your understanding of the binder mechanism?
Binder is an IPC mechanism, a tool for inter-process communication.
The Java layer can use the aidl tool to implement the corresponding interface.

4. What are the implementation methods of inter-process communication in Android?
Intent, Binder (AIDL), Messenger, BroadcastReceiver

5. Introduce the basic process of implementing a custom view
1. Write the attr.xml file for the properties of the custom View
2. Reference it in the layout layout file and reference the namespace
3. Obtain our custom one in the construction method of the View Attribute, read in the custom control (the construction method gets the value of the attr.xml file)
4. Rewrite onMesure
5. Rewrite onDraw

6. What is the delivery mechanism of touch events in Android?
1. The APIs related to touch event delivery include dispatchTouchEvent, onTouchEvent, and onInterceptTouchEvent
2. The classes related to touch events include View, ViewGroup, and Activity
3. Touch events will be encapsulated into MotionEvent objects , this object encapsulates gesture press, move, release and other actions
4. Touch events are usually sent from Activity#dispatchTouchEvent, as long as they are not consumed, they will be passed down to the bottom View.
5. If each View to which the Touch event is delivered does not consume the event, then the Touch event will be passed upward in the reverse direction, and will eventually be processed by Activity#onTouchEvent. 6. OnInterceptTouchEvent is
unique to ViewGroup and can intercept the event.
7. When the Down event arrives , if a View does not consume the event, then subsequent MOVE/UP events will not give it

7. Briefly describe the RecyclerView caching mechanism?

RecyclerView can be said to have replaced listview in Android applications. Its flexible, assembled settings, and multi-caching mechanism can adapt to the various needs of multi-list in Android development.
For the caching mechanism of RecyclerView, I have always wanted to think a little bit more. To put it simply, RecyclerView has two layers of caching support in comparison with listview caching mechanism. Listview is a two-level cache, and RecyclerView is a four-level cache (of course, in most cases. is the L3 cache).

8. In a listview, each item has an animation (gif) view, and when I click the button in the item, the animation (gif) plays. Sliding the listview when there is animation playing, occasionally the event of item misplacement will occur. what is the reason?

This is a problem of item reuse, and the image is misplaced due to asynchronous loading

9. What are the implementation methods of Android multi-threading?
Thread & AsyncTask
Thread can be shared with Loop and Handler to create a message processing queue
AsyncTask can be used as a thread pool to process multi-tasks in parallel

10. When to use multi-process in Android development? What are the benefits of using multiple processes?
If you want to know how to use multi-process, you must first know the concept of multi-process in Android. Generally, an application program is a process, and the process name is the application program package name. We know that a process is the basic unit of system resource allocation and scheduling, so each process has its own independent resources and memory space, and other processes cannot arbitrarily access the memory and resources of other processes.
So how to make your application have multiple processes?

Very simple, when our four major components are registered in the AndroidManifest file, there is an attribute of android:process,

1. Here you can specify the process of the component. The default is the main process of the application. After being designated as another process, when the system starts this component, it will first create (if it has not been created) this process, and then create this component. You can overload the onCreate method of the Application class, print out its process name, and you can see it clearly. When setting the android:process attribute, there is one thing to pay attention to: if it is android:process=":deamon", the name starting with: means that this is a private process of the application, otherwise it is a global process. The process name of the private process will automatically add the package name before the colon, but the global process will not. Generally, we have private processes and rarely use global processes. I don't know if anyone can add the specific difference between them.

2. The obvious benefit of using multiple processes is to share the memory pressure of the main process. Our application is getting bigger and bigger, with more and more memory. Putting some independent components into different processes, it will not occupy the memory space of the main process. Of course, there are other benefits. Those who are interested will find that there are many applications in the Android background process that have multiple processes, because they have to stay in the background, especially instant messaging or social applications, but now multi-process has been used badly. Typical usage is to start an invisible lightweight private process, send and receive messages in the background, or do some time-consuming things, or start the process at startup, and then do monitoring, etc. Another is to prevent the main process from being killed by the daemon process. The daemon process and the main process monitor each other, and restart it if one of them is killed. There should be other benefits, so I won’t go into details here.

3. The disadvantage is that it takes up more space in the system. If everyone uses it like this, the system memory will easily fill up and cause freezes. Consume the user's battery. The application architecture can become complex due to the need to handle communication between multiple processes. Here is another question.

11. What is the common way to solve sliding conflicts under Android?
The relevant sliding components rewrite onInterceptTouchEvent, and then judge whether to intercept the current operation based on the xy value

12. How to set an application as a system application?
To become a system application, it must first be compiled under the Android source code SDK of the corresponding device. After compiling:
this Android device is a Debug version and has been rooted, directly push this apk to system/app or system/priv-app with the adb tool That's it.
If it is a non-root device, you need to compile and re-program the device image.

Some permissions (such as WRITE_SECURE_SETTINGS ) are not open to third-party applications, and can only be compiled in the corresponding device source code and then used as a system app.

13. Research on Android memory leaks
Android memory leaks refer to certain objects (garbage objects) in the process that are no longer useful, but they can directly or indirectly refer to gc roots and cannot be recycled by GC. Useless objects occupy the memory space, making the actual usable memory smaller, which is a memory leak.
Scenario
Static variables of a class hold large data objects
Static variables maintain long-term references to large data objects, preventing garbage collection.
Static instance of non-static inner class
The non-static inner class will maintain a reference to the instance of the outer class. If the instance of the non-static inner class is static, it will indirectly maintain the reference of the outer class for a long time, preventing it from being recycled.
Resource objects are not closed
Resource objects such as Cursor, File, and Socket should be closed in time after use. If it is not closed in finally, it will lead to the hidden danger that the resource object will not be released under abnormal conditions.
The registered object is not unregistered.
Failure to unregister will cause the reference of the object to be maintained in the observer list, preventing garbage collection.

Handler temporary memory leak
Handler interacts with the main thread by sending Message, which is stored in MessageQueue after sending, and some Messages are not processed immediately.

There is a target in the Message, which is a reference to the Handler. If the Message exists in the Queue longer, the Handler cannot be recycled. If the Handler is non-static, the Activity or Service will not be recycled.

Since AsyncTask is also a Handler mechanism inside, there is also a risk of memory leaks.
This kind of memory leak is generally temporary.

at last

I usually read the technical articles of the following good official accounts. They often write some interview experience, interview question solutions, and also organize a lot of free series materials and learning materials. They are practical but not impetuous, and do not sell anxiety. I hope everyone will make progress together and be ready at all times.

In 2023, the latest Android interview major manufacturers must take 174 questions (with detailed answers)

Every peak season of recruitment is a good time for programmers to change jobs and raise their salaries. If the gold medals, silver medals, and silver medals are not caught up, the upcoming gold medals, nine silver medals, and ten silver medals should not be missed. If you want to get more opportunities and take your life to a higher level, you must be fully prepared. For Android developers, mastering certain review methods and interview skills will make your review more effective and greatly improve the chances of passing the first two rounds of technical interviews.

The following latest version of " 174 Questions Required for Android Interviews at Major Manufacturers " contains high-frequency questions from major manufacturers and the latest technology in the industry. It was compiled and improved by the boss of Ali P6 in two months. The structure is clear, very suitable for partners who want to apply for a job/change job! !

Content summary: Connotation Bytedance, Xiaomi, oppo, Meituan, Alibaba, Tencent, 360, Huawei, Jingdong and other first-tier Internet companies interview technical real questions.

Reference analysis: Bytedance technical team, Guo Lin, Hong Yang , Yu Gang, Nuggets blogger xiangzhihong, Focusing, simpleeeeee, DevYK, Jianshu blogger huangLearn, Tencent Xiangxue Classroom, MOOC, Geek Time...

Due to the large content of the article and the limited space, the information has been organized into a PDF document. If you need the complete document of "174 Questions Required for Android Interviewing Manufacturers", you can add WeChat to get it for free!

" 174 questions that Android interview manufacturers must take "

outline

1. SD card

2. Android data storage method

3. BroadcastReceiver

4. What are the consequences of frequent sp operations? How much data can sp store?

5. The difference between dvm and jvm

6. ART

7. Activity life cycle

img

8. Can the Application start the Activity?

9. What are the states of the Activity?

10. What are the life cycle of the Activity when switching between horizontal and vertical screens? What are the states of the Activity?

11. How to set the activity into a window style

12. How to start the Activity

img

13. Service life cycle

14. IntentService

15. Fragment and Activity onCreateOptionsMenu

16. Service's onStartCommand has several return values

17. Under what circumstances does Service's onRebind execute?

18. Handler prevents memory leaks

19. Matching rules of IntentFilter

20. Fragment and Activity pass value

21. Fragment life cycle

img

22. The difference between add and replace of Fragment//replace==remove|append

23. How does Fragment implement the push and pop of the Activity stack

24. Under what circumstances does memory leak occur?

25. The picture is too large to cause OOM

26. The difference between SoftReference and WeakReference

27. dp and px

28. Set the layout to half width and height

29. Manifest file configuration for multi-resolution support

30. Android event distribution mechanism

img

31. The difference between ArrayList and LinkedList

32. LruCache

33. What is ANR and how to avoid it

34. Describe how the Service is started

35. What kinds of layouts does Android have?

img

36. The difference between HashMap and HashTable//from thread safety and speed

37. Red-black tree

38. How Handler Looper works

39. Introduction to several adapters of Listview

40. How to add a dividing line between ListView

41. Interpretation of LinkedHashMap source code

42. Drawable to Bitmap

43. Layout_weight

44. The difference between android:layout_gravity and android:gravity

45. How to reuse layouts

46. ​​Use merge to reduce the layout level caused by the include layout

47. How to optimize the layout

img

48. Rules for using android:layout_gravity

49. TextView display image

50. Use of SpannableString

51. Use of AutoCompleteTextView

52. What are the ways to display images on buttons

53. How to dynamically change the size and position of Button

54. How to make a button that displays images display different images in different states

55. How to achieve translucency in images

56. HttpURLConnection

57. ProgressBar

58. AbsListView

59. ListView, how to add, delete, modify and check data

60. How to display the data in the database in ListView

61. android TypedArray

62. How to dynamically load the class of the apk file (not installed)

63. Android ContentProvider

64. How to set Activity as the default Activity started by the program

65. Several ways to start Activity

img

66. The way Activity transfers data

67. How to set the Activity as a translucent modal box

68. How to receive broadcast

69. How to get SMS content

70. How to intercept mobile phone screen sleep and wake up

71. How to send a broadcast

72. AIDL and Service

73. How to read contact information

img

74. Please describe what parts the uri of the Content Provider consists of

75. Introduce the steps to develop ContentProvider

76. How to add access rights to ContentProvider

77. AlertDialog

78. How to control the closing timing of the dialog box by yourself

79. How to change the transparency of the dialog box

80. How to control the display and closing of Toast by yourself

81. How to use Notification

img

82. PendingIntent uses //cross-process intent

83. Click on Notification to trigger Activity jump

84. How to customize the view of Notification

85. Then add an option menu for an Activity

86. How to bind the context menu to the visual component View

87. When clicking the menu, how can I jump into another Activity

88. What are the callback functions of the menu?

img

89. How to use SharedPreferences to access data

90. SharedPreferences //constructor (string name, int mode)

91. How does Android parse xml files

92. gson

93. How to copy the data and structure of table1 to table2

94. SQLite

95. Where do SQLiteOpenHelper.getReadableDatabase and SQLiteOpenHelper.getWritableDatabase put the database file

96. Then release the SQLite with data together with the apk

97. After the Socket connection is successful, how to get the IP and domain name of the server

98. BufferedInputStream mark //Only BufferedInputStream implements the mark method

99. How to turn on the Bluetooth function in the mobile phone

img

100. How to get the bound Bluetooth device

101. What states do you go through in the process of searching for Bluetooth?

102. Implicit Intent

103. How to use broadcast to monitor outgoing and incoming calls

104. Phone state supported by Android

105. How does Android control answering and hanging up calls

106. Please give the Content Provider URI to access the call log

107. Send SMS//Requires dynamic request permission: android.permission.SEND_SMS

108. ContactsContract

109. VideoView Play video

img

110. Store tree.png in res/drawable under the project path, if the picture is displayed on the View

111. Call Drawable for drawing

112. How to set image transparency

113. How to rotate View

114. Activity switching

115. Android

img

116. Animation

117. Property animation Animator

118. Define a string array resource

119. Layer layer resources

120. Clip image resources

121. ShapeDrawable

122. How to uniformly set the android:textSize and android:textColor of multiple Views

123. The meaning of "@", "+", "?" in the layout file of attribute animation Animator****123

124. How to get screen height and width in Android

125. AsyncTask

126. Intent transferable data type

127. AlarmManager //alarm clock

128. HandlerThread

129. Custom ViewGroup

img

130. GC algorithm of JVM

131. OkHttp

132. ButterKnife //Source code reading

133. Dalvik memory model

134. ART Garbage Collection

135. Which objects can be used as root nodes in JVM reachability analysis

136. HashSet

137. Symmetric and Asymmetric Encryption in SSL

138. Handler memory leak problem

img

139. Android volatile keyword

140. EventBus source code reading//reflection Class usually uses wildcards =>Class<?> or Class<? extends T>

141. String a="abc";String b="abc"; Created several objects//The stack stores the reference variable heap in the new object, and divides a part of the heap as a constant pool

142. java singleton creation

143. Android process priority

144. ThreadLocal source code

145. Custom View object

img

146. Android @Override //Rewrite

147. Android Semaphore mechanism

148. Android Lock Synchronization

149. ThreadPoolExecutor thread pool

150. Android downloads pictures and sets ImageView through bitmap

151. ImageView

152. onSaveInstanceState //Save the app data, when the system destroys the app due to insufficient memory, it will be called

153. ViewPager&PagerAdapter&TabFragmentPagerAdapter

154. Fragment data saving when switching between horizontal and vertical screens

155. DialogFragment //It is used by subclass inheritance. Compared with AlertDialog, FragmentManager is responsible for automatic reconstruction

156. SQLiteDatabase

157. IntentFilter matching rules

158. Android multi-process

img

159. Android Scroller

160. Sqlite connection operation

161. Spinner

162. RelativeLayout source code

163. Message //static Message sPool, pointing to the available Message objects at the front of the queue

164. ArrayDeque source code reading

165. RecyclerView

166. LinearLayoutManager //RecyclerView's layout manager

167. GridLayoutManager

168. RecyclerView usage

169. Binder

img

170. ActivityThread //The main thread of the Android application

171. CountDownLatch thread synchronization

172. retrofit

173. ClassLoader class loader

174. RxJava

Due to the large content of the article and the limited space, the information has been organized into a PDF document. If you need the complete document of "174 Questions Required for Android Interviewing Manufacturers", you can add WeChat to get it for free!

Guess you like

Origin blog.csdn.net/Android23333/article/details/129421406