How will you respond to the most complete 30 Android interview questions in 2017?

Source: Internet
Author: User

Baidu Home Login 2017 the most complete 30 Android interview questions, how will you answer?

Wing Technology

hundred 03-10 02:32

"Three gold four silver" is also the annual job-hopping season, I believe that a lot of Android programmers began to get ready. However, in the face of the interviewer's question, how will you answer?

First, how to understand the relationship between the three Activity,view,window?

That's a really bad question to answer. So first the appropriate metaphor to describe their relationship, activity like a Craftsman (Control Unit), window like Windows (Load model), view like window grilles (display view) Layoutinflater like scissors, XML configuration like a grilles drawing.

1:activity constructs a window when initialized, which is exactly the Phonewindow.

2: This phonewindow has a "viewroot", this "Viewroot" is a view or ViewGroup, is the most initial root views.

3: "Viewroot" through the AddView method to add a view. such as Textview,button, etc.

4: These view events are monitored by windowmanagerservice to receive messages and callback activity functions. such as Onclicklistener,onkeydown and so on.

Ii. several launchmode and usage scenarios of activity

1. Standard mode

This is the default mode, and the activity instance is created each time the activity is activated and placed in the task stack. Usage scenario: most activity.

2. Singletop mode

If there is an instance of the activity at the top of the task, the instance is reused (Onnewintent () of the instance is invoked), otherwise a new instance is created and placed on top of the stack, even if an instance of the activity already exists in the stack, and a new instance is created as long as it is not at the top of the stack. Use scenes such as news or reading content pages of the app.

3. Singletask mode

If an instance of the activity is already in the stack, the instance is reused (Onnewintent () of the instance is invoked). When reused, the instance is returned to the top of the stack, so instances above it will be moved out of the stack. If the instance does not exist in the stack, a new instance is created to be put into the stack. Use scenes such as the browser's main interface. Regardless of how many apps launch the browser, only the main interface is started once, the rest will go onnewintent, and the other pages above the main interface will be emptied.

4. SingleInstance mode

Create an instance of the activity in a new stack and have multiple apps share that activity instance in the stack. Once the activity instance of the pattern already exists in a stack, any application that activates the activity will reuse the instance in that stack (the onnewintent () of the instance is invoked). The effect is that multiple apps share an app, regardless of who activates the Activity into the same app. Use scenes such as alarm reminders to separate alarm alarms from alarm settings. SingleInstance do not use in the middle page, if used in the intermediate page, jump transfer problems, such as: A-B (singleinstance)-C, after the full exit, this start, first opened is B.

Iii. What are the types of animations in Android?

There were 2 species before Android3.0, 3.0 were 3.

Frameanimation (Step-by-frame animation): Combining multiple pictures to play, similar to how early movies work, many apps loading this way.

Tweenanimation (Motion Tween): A series of animations of a view, including fade (Alpha), scale, pan (Translate), rotation (Rotate), four modes.

Propertyanimation (Property Animation): Property animation is no longer just a visual effect, but rather a mechanism for constantly manipulating values and assigning values to the specified properties of a specified object, which can be any property of any object.

http://blog.csdn.net/yanbober/article/details/46481171

Iv. describe the life cycle of your activity

The key to this problem is understanding. Some people have encountered the problem of variant question, ask OnStart (), and Onresume () What is the difference? If the interviewer throws the question, isn't it a little unprepared. Recently, someone else has suffered a more perverted question: Under what circumstances the activity goes oncreat (), rather than walking OnStart ().

V. Please describe the service life cycle

Note that there are two ways to start a service, StartService () and Bindservice ()

Vi. Drawing process of view

Measure process, layout process, draw process

http://blog.csdn.net/yanbober/article/details/46128379/

Vii. What are the four components of Android, and what are their respective roles?

Activity:activity is the window of the Android program interacting with the user, is the most basic of the Android building block, it needs to maintain the state of the various facets, do a lot of persistent things, properly manage the life cycle and some jump logic.

Service: Background services for activity, encapsulation has a complete functional logic implementation, accept the upper instruction, complete the related things, define the need to accept the intent provide synchronous and asynchronous interface.

Content Provider: is a third-party application data Access program provided by Android, can derive content Provider class, provide data to the outside, can choose sort like database, block the storage details of internal data, provide a unified excuse model, Greatly simplifies the upper application, and provides a more convenient way to integrate the data.

Broadcast receiver: Accepts one or more intent as triggering events, accepts related messages, does some simple processing, transforms into a notification, and unifies the Android event broadcast model.

Eight, the optimization of the ListView solution

1, if the custom adapter, then in the GetView method to consider the method passed in the parameter contentview is null, if it is null to create Contentview and return, if not NULL is directly used. Create as few view as possible in this method.

2, to Contentview set tag (Settag ()), passed in a Viewholder object, used to cache the data to be displayed, can achieve the effect of asynchronous loading of image data.

3. If the ListView needs to display a lot of item, you should consider paging load.

Nine, there are several ways to communicate across processes in Android

1: Access the activity of other applications, such as calling the system call Application Intentcallintent=newintent (Intent.action_call,uri.parse ("tel:12345678"); StartActivity (callintent);

2:content Provider, such as access to the System album

3: Broadcast (broadcast), such as display system time

4:aidl Service

Ten, the principle of the MVC model, its use in Android, Android's official recommendation application development using MVC mode.

MVC is an acronym for Model,view,controller, and MVC consists of three parts:

1) Model object: Is the main part of the application, and all business logic should be written on that layer.

2) View object: Is the part of the application that is responsible for generating the user interface. It is also the only layer that the user can see in the entire MVC architecture, receiving input from the user and displaying processing results.

3) Controller (Control) object: is based on user input, control user interface data display and update model object state of the part of the controller more important a navigation function, in response to the user started related events, to the M layer processing.

Android encourages weak coupling and component reuse, and MVC in Android is embodied in the following:

1) View layer: The general use of XML file interface description, when used can be very convenient to introduce, of course, if you know more about Android, you can think of Android can also use javascript+ HTML and so on as the view layer, of course, there is a need for the communication between Java and JavaScript, fortunately, Android provides a very convenient communication between them implementation.

2) control layer (Controller): The task of Android control layer usually falls on the shoulders of many acitvity, this phrase also implies do not write code in acitivity, to through activity delivery model business Logic layer processing, Another reason for this is that the response time of Acitivity in Android is 5s, and if time-consuming operations are put here, the program is easily recycled.

3) Model: the operation of the database, the operation of the network, etc. should be processed in the model, of course, business calculations and other operations must be placed in the layer.

Xi. what will lead to force Close? How to avoid it? Can I catch the exception that caused it?

There are exceptions to the program, such as Nullpointer. How to avoid: logical coherence and thoughtful thinking when writing programs. Can catch exceptions, and can see abnormal information in Logcat

12, the touch event transmission mechanism publicbooleandispatchtouchevent (MOTIONEVENTEV); Used to assign eventpublicbooleanonintercepttouchevent (MOTIONEVENTEV);//used to intercept eventpublicbooleanontouchevent ( MOTIONEVENTEV);//For handling event

Where the activity and view controls (TextView) have an assign and handle event method, the View container (LinearLayout) has an assign, intercept, and handle event method. Here also has a metaphor: The leadership will assign the task downward, once the following people do not do well, will not be the follow-up task to the following people to do, can only do their own, if they can not do, can only tell the superior can not complete the task, the superior will repeat his process. In addition, the leadership has the right to intercept the task, the subordinate to conceal the task, and directly to do, if not done, can only report to the superior can not complete the task.

Http://gold.xitu.io/entry/56af0ba0c24aa800547b60ea

http://blog.csdn.net/morgan_xww/article/details/9372285

13. Please say something about Android UI adaptation

Hongyang Plan of the Great God: http://blog.csdn.net/lmj623565791/article/details/45460089

14, please introduce the Java annotation reflection principle is what

Reference: http://www.jianshu.com/p/3968ffabdf9d

XV, please say the database optimization problem

Reference: HTTP://WWW.JIANSHU.COM/P/3B4452FC1BBD

16, please describe how the next contentprovider is to achieve data sharing

A program can completely expose its own data by implementing a content provider abstraction interface, and content providers exposes data in a similar way to tables in a database. Content providers stores and retrieves data, which allows all applications to access, which is the only way to share data between applications.

There are 2 ways to make your application's data public: Create a content provider of your own or add your data to a content provider that already exists, provided it has the same data type and has write content The permissions of the provider.

How can I get data exposed by other applications through a set of standard and unified interfaces?

Android provides contentresolver that external programs can access the data provided by the ContentProvider via the Contentresolver interface.

17, Hybridjava and JS interaction

Reference: Http://droidyue.com/blog/2014/09/20/interaction-between-java-and-javascript-in-android/

18, please introduce the Java GC principle

Reference: Http://www.jianshu.com/p/d75a32ac5bed?

19. How to set an activity as a window style.

Medium configuration: Android:theme= "@android: Style/theme.dialog"

Additionally Android:theme= "@android: Style/theme.translucent" is set to transparent

20, Java Annotation Reflection principle problem

21, what is the ANR how to avoid it?

Anr:application not responding. In Android, the two system services, Activity Manager and window manager, are responsible for monitoring the response of the application, and when the user operates within 5s and the application fails to respond, the broadcastreceiver does not complete within 10 seconds, and the Application Unresponsive dialog box appears. This is both ANR.

Avoidance method: Activity should do as little as possible in its critical life-cycle methods (such as OnCreate () and Onresume ()) to create operations. Potentially time-consuming operations, such as network or database operations, or high-time calculations such as changing the bitmap size, should be done in the thread (or async) of the Strand. The main thread should provide a handler for the child thread so that it can be submitted to the main thread when it is complete.

22. Design mode

Reference: http://gold.xitu.io/entry/56ebb4ad5bbb50004c440972

23. The API of Android itself does not declare that it throws an exception, is it possible to throw runtime exception at runtime, have you ever encountered it? What problems will be caused by Noyo words? How is it solved?

Will, like NullPointerException. I have encountered, such as Textview.settext (), TextView not initialized. Causes the program to fail to function correctly when forceclose occurs. Open the console to view logcat information to find the exception information and modify the program.

24, RxJava

Http://gank.io/post/560e15be2dca930e00da1083?from=timeline&isappinstalled=0#toc_1

25. Http Https

Http://www.jianshu.com/p/93fdebe5fef1

26. How to reference the local language in Java

You can use the JNI (Java Native Interface Java local interface) interface.

27. Android Memory leak and management

http://gold.xitu.io/entry/56d64b9e816dfa005943a55c

28, design a set of pictures asynchronous load caching scheme

Http://www.cnblogs.com/zyw-205520/p/4997863.html

http://blog.csdn.net/boyupeng/article/details/47127605

29. What kinds of XML-parsing classes are in Android? What kind of official recommendation is it? What are their principles, and what are the differences?

A: There are three main ways of parsing XML, SAX, DOM, pull. General development on the PC we use the DOM relatively easy, but some performance-sensitive database or mobile phone is mainly sax, sax read is one-way, the advantages: not account for memory space, parsing properties convenient, but the disadvantage is that nested multiple branches for processing is not very convenient. And Dom Way will load the entire XML file into memory, where the Android Development network to remind you that the method in the search aspect can and XPath good combination if the amount of data is not highly recommended, and pull is often used in J2ME for node processing is better, similar to sax mode, Also very memory-saving, in J2ME we often use the Kxml library to parse.

30, the principle of heat repair

1:javasisst

2:aspectj

3:xposef

http://mp.weixin.qq.com/s?__biz=MzA3Mjk1MjA4Nw==&mid=400452659&idx=1&sn= 841b49b875ec3b307f261ed52a7d9c4e&scene=23&srcid=1119jwrt0adnwgxthiyok460#rd

The network, perpendicular to the Internet industry, the job recruitment platform. Focus on operations, promotion, marketing, SEO, SEM, BD, product Manager, technology development and other job openings. Pay attention to the recruitment network of the public number yuepin51 to obtain the latest and most comprehensive job search information, release only your micro resume, micro recruitment.

How will you respond to the most complete 30 Android interview questions in 2017?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.