In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of what the seven questions are often asked in the Android interview, the content is detailed and easy to understand, the operation is simple and quick, and has a certain reference value. I believe you will gain something after reading the seven questions in the Android interview. Let's take a look.
1. The four components of Android and their functions
Activity:Activity is the window through which Android programs interact with users, and it is one of the most basic building blocks of Android. It needs to do a lot of persistence things, properly manage the life cycle and some jump logic in order to maintain the state of each interface.
Service: backstage service for Activity, encapsulated with a complete functional logic implementation, accepts instructions from the upper layer, completes related actions, and defines the Intent to be accepted to provide synchronous and asynchronous interfaces.
Content Provider: it is a third-party application data access scheme provided by Android, which provides data to the outside, shields the storage details of the internal data, and provides a unified excuse model, which greatly simplifies the data integration of the upper application.
BroadCast Receiver: accept one or more Intent as trigger events, accept related messages, do some simple processing, and convert them into a Notification, unifying the event broadcasting model of Android.
2. Describe the life cycle of Activity?
The life cycle methods of Activity are: onCreate (), onStart (), onReStart (), onResume (), onPause (), onStop (), onDestory ()
Visible life cycle: from onStart () until the system calls onStop ()
Foreground life cycle: from onResume () to system call onPause ()
Activity lifecycle when the screen is rotated:
When the android:configChanges of Activity is not set, screen cutting will re-invoke each life cycle, once when horizontal screen is cut, and twice when vertical screen is cut.
When setting the android:configChanges= "orientation" of Activity, screen cutting will still re-invoke each life cycle, and horizontal and vertical screens will only be executed once.
When setting the android:configChanges= "orientation | keyboardHidden" of Activity, screen cutting will not re-invoke each lifecycle, only the onConfigurationChanged method will be executed.
3. What are the ways to optimize ListView?
1) the layout of item in ListView is very important, and the use of controls and layouts must be reduced as much as possible.
2) RelativeLayout is an absolute weapon, through which you can reduce the level of layout.
3) at the same time, reuse controls as much as possible, which can reduce the memory use of ListView and reduce the number of GC when sliding.
4) the background color of ListView is the same as that of cacheColorHint, which can improve the rendering performance when sliding.
5) complex logical calculations, especially database operations, cannot be done in the getView method, otherwise the performance of sliding will be seriously affected.
4. Explain the operation mechanism of Handler?
Message, which is understood as information communicated between threads
Handler, the main processor of Message, is responsible for the sending and execution of Message
Message Queue, which is used to store messages posted through Handler, based on first-in, first-out execution
Looper, the butler of the Message Queue in each thread
The Handler is generally created in the main thread, and the child thread sends a message to the
In MessageQueue (message queue), the main thread already contains a Looper (rotator). Looper is an endless loop and will always poll the message queue to see if there is a Message (message). If so, the poller will pass the message object to Handler (message processor), and then call handlerMessage to process the message, and then update the UI.
5. What is ANR? How to avoid ANR exception?
ANR:Application Not Responding . In Android, two system services, activity manager and window manager, are responsible for monitoring the response of the application. When the application operated by the user fails to respond within 5 seconds, and the BroadcastReceiver is not completed within 10 seconds, there will be an application silent response dialog box, which is ANR.
Avoidance: Activity should do as little creation as possible in its key lifecycle methods such as onCreate () and onResume (). Potentially time-consuming operations, such as network or database operations, or time-consuming calculations such as resizing bitmaps, should be done in child threads (or asynchronously). The main thread should provide a Handler for the child thread so that it can be submitted to the main thread when it is finished.
6. What are the characteristics and differences of the three kinds of animation in Android?
The animations in Android include frame animation, tween animation, and attribute animation.
Frame animation: pictures are constantly switched to form an animation effect, similar to a childhood movie. Many applications use loading in this way.
Motion tween: a series of animation operations for a View, including Alpha, Scale, Translate, and Rotate modes.
Attribute animation: attribute animation is no longer just a visual effect, but a mechanism for constantly manipulating values and assigning values to the specified properties of a specified object, which can be any attribute of any object.
7. There are several ways to register for broadcasting. What are the advantages and disadvantages?
First: declare in the manifest file, add
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.