Android recruitment face question Answer _android

Source: Internet
Author: User
General Simple Questions
1. Android DVM process and Linux process, is the application process the same concept?
DVM refers to a dalivk virtual machine. Each Android application runs in its own process and has a separate Dalvik virtual machine instance. And every DVM is a process in Linux, so it can be considered the same concept.
2. What is the function of the EF file of the SIM card?
The SIM card file system has its own specifications, mainly to communicate with the mobile phone, the SIM itself can have its own operating system, the EF is for storage and communication with the mobile phone.
3. What kinds of embedded operating system memory management, what are the characteristics of each?
Page type, segment type, section page, use MMU, virtual space and other technology.
4. What is an embedded real-time operating system and does the Android operating system belong to the real-time operating system?
Embedded real-time operating system means that when an external event or data is generated, it can be accepted and dealt with fast enough speed, and the result of processing can control the production process or respond quickly to the processing system, and control the embedded operating system with all real-time tasks running in a coordinated and consistent operation. Mainly used in industrial control, military equipment, aerospace and other areas of the system response time is demanding, this requires the use of real-time systems. Also can be divided into soft real-time and hard real-time two kinds, and Android is based on the Linux kernel, so belong to soft real-time.
5. How many byte is the longest short message?
Chinese 70 (including punctuation), English 160 bytes.
6. What are the types of animations in Android, and what are their characteristics and differences?
Two kinds, one is tween animation, there is also a frame animation. Tween animation, which enables the view component to move, zoom in, zoom out, and create transparency changes; another frame animation, traditional animation method, through the sequential playback of good pictures to achieve, similar to movies.
7. Principle of handler mechanism
Andriod provides Handler and Looper to meet the communication between threads. Handler advanced First out principle. The Looper class is used to manage the exchange of messages between objects within a particular thread (message exchange).
Looper: A thread can produce a Looper object that manages the message queue for this line Chengri.
Handler: You can construct Handler objects to communicate with Looper to push new messages into message queue, or to receive messages sent by Looper from message queue.
Message queue: A message that is used to hold a thread into.
Thread: UI thread is usually the main thread, and Android launches a message Queue for the program.
8. Talking about the principle of the MVC pattern, its application in Android
MVC (Model_view_contraller) "Model _ View _ Controller". An MVC application is always made up of these three parts. Event causes controller to change model or view, or both. All dependent view updates automatically as long as the controller changes the models data or attributes. Similarly, as long as controller changes the View,view will get the data from the potential model to refresh itself.
View redraw and memory leaks
View redraw and memory leaks seem to be questions often asked by the interviewer.
1. View Refresh:
In the place where you need to refresh, use Handle.sendmessage to send the message, and then execute invaliate or postinvaliate in handle's getmessage.
2. GC Memory leaks
The situation occurs:
The cursor of the database is not closed.
The cache Contentview is not used when constructing adapter. The optimization problem of derivative ListView: Reduce the creation of view objects, the full use of Contentview, you can use a static class to optimize the process of processing getview.
The Bitmap object uses recycle () to free memory when it is not in use.
Objects in the activity have a life cycle greater than the activity.
Activity
1. The life cycle of activity
As with other mobile platform applications, the lifecycle of Android apps is unified, meaning that the fate of the applications we write is in the hands of others, we can't change it, we can only learn and adapt to it.
Simply say why it is: Our mobile phone is running, an application, it is possible to call in the incoming text message, or no electricity, this time the program will be interrupted, priority to serve the basic functions of the telephone, the other system does not allow you to occupy too much resources, at least to ensure that the telephone function bar, So it's possible to get killed when there's not enough resources. Again, the basic lifecycle of an activity is shown in the following code:
Copy Code code as follows:

public class MyActivity extends activity{
protected void OnCreate (Bundle savedinstancestate);
protected void OnStart ();
protected void Onresume ();
protected void OnPause ();
protected void onStop ();
protected void OnDestroy ();
}

The activity that you write yourself will overload these methods as needed, onCreate is unavoidable, in the process of an activity starting normally, they are called OnCreate-> OnStart->onresume, In the activity was killed when the order is OnPause-> onStop-> OnDestroy, this is a complete life cycle, but someone asked, the program is running on the phone, this procedure? Stop chant, if the new activity is full screen when the suspension is so: onpause->onstop, restore when onstart->onresume, if interrupted this application is a theme for translucent Or dialog activity is just onpause, and when it's time to recover Onresume. Describe in detail what the system is doing in these methods and what we should do:
OnCreate: Create an interface here and do some initialization work on the data.
OnStart: This step becomes user-visible and not interactive.
Onresume: To become interactive with the user, (at the top of the activity stack system managing the activity on the stack, running the pop-up stack, back to the previous activity).
OnPause: To this step is visible but not interactive, the system will stop the animation and other CPU-consuming things from the above description already know, should be here to save some of your data, because this time your program's priority reduction, it is possible to be the system back. The data stored here should be read in the Onresume, note: This method is done in a short time, because the next activity will not wait until this method is completed before starting.
OnStop: becomes invisible and is covered by the next activity.
OnDestroy: This is the last called method before the activity is killed, possibly the outer class calls the Finish method or the system to save space to temporarily kill it, you can use isfinishing () to judge it, if you have a progress dialog in the thread, please cancel it in the OnDestroy, or the Cancel method that calls dialog will throw an exception when the threads end.
Onpause,onstop, OnDestroy, three state activity can be eliminated in order to ensure the correctness of the program, you have to write in the OnPause () of the persistence layer operation code, the user edits are saved to the storage media (typically database). There are also a lot of problems in the actual work because of the change of life cycle, such as your application started a new thread running, this time interrupted, you have to maintain the thread, is suspended or killed or data rollback, right? Because the activity may be killed, so the variables used in the thread and some of the interface elements must be noted, I usually use the android message mechanism [Handler,message] to deal with multithreading and interface interaction problems. I'll talk about it later, because these things have a big head, and I'll share with you when I get my thoughts straight.
2. Let the activity become a window: Activity attribute setting
It's easy to say, maybe someone wants to make an application that floats in the main interface of the phone, so it's simple you just have to set up the subject of the activity to define the activity in Androidmanifest.xml:
Copy Code code as follows:

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

This makes your application appear in the form of a dialog box, or
Copy Code code as follows:

Android:theme= "@android: Style/theme.translucent"
Android:theme= "@android: Style/theme.translucent"

becomes translucent, and similar to the properties of this activity can be on Android. The Androidmanifestactivity method of the R.styleable class is seen in the Androidmanifest.xml the attributes of all the elements in this class can refer to the android.r.styleable above is the name of the property, what the value is in the Android.r.style can be seen, such as this "@android: Style/theme.dialog "corresponds to Android. R.style.theme_dialog, (' _ ' replaced by '. ') can be used in the description file, look for the class definition and description of the corresponding relationship between the document is understood.
3. What do you do in your backstage activity being recycled by the system: Onsaveinstancestate
When one of the activity A in your program runs, actively or passively running another new activity B this time a will execute the Java code:
Copy Code code as follows:

public void Onsaveinstancestate (Bundle outstate) {
Super.onsaveinstancestate (outstate);
Outstate.putlong ("id", 1234567890);
}

B after completion and will come to find a, this time there are two cases, one is a is recycled, one is not recycled, is recycled a will be called onCreate () method, different from the direct start is this back onCreate () is with the parameter savedinstancestate, It's better to be onresume without being taken back.
Savedinstancestate is a bundle object that you can basically interpret as a map object that the system helps you maintain. You may use it in OnCreate (), and if you start oncreate it will not have it, so use the time to determine whether it is empty.
Copy Code code as follows:

if (Savedinstancestate!=null) {
Long ID =savedinstancestate.getlong ("id");
}

Just like in the official Notepad tutorial, you're editing a note that's suddenly interrupted, so just remember the ID of this one, and then you can get it out of this ID, and the program is complete. This is also to see your application need not to save anything, such as your interface is to read a list, it does not need special to remember what, oh, maybe you need to remember the position of the scroll bar ...
4. Call and be called: our Messenger of communications intent
To say intent, intent is this intention, the application intent Exchange, make a phone call, a phone will send intent, this is the Android architecture of the essence of loose coupling, greatly improve the reusability of components, For example, if you want to click a button in your application and call someone, it's very simple, look at the code first:
Copy Code code as follows:

Intent Intent = new Intent ();
Intent.setaction (Intent.action_call);
Intent.setdata (Uri.parse ("Tel:" + number));
StartActivity (Intent);

Throwing out such an intention, the system to see your intentions to wake up the phone dialer, typed the phone. What to read contact person, send text message ah, mail ah, all just need to throw out intent is good, this Part design is really very good.
What does the intent tell the system who needs to accept him? There are usually two ways to use intent, the first of which is to directly indicate which class is needed to receive the code as follows:
Copy Code code as follows:

Intent Intent = new Intent (this,myactivity.class);
Intent.getextras (). putstring ("id", "1");
StartActivity (Intent);
Intent Intent = new Intent (this,myactivity.class); Intent.getextras (). putstring ("id", "1"); tartactivity (Intent);

The first approach is obvious, directly designating the myactivity as the recipient, and passing some data to myactivity, which can be getintent () to this intent and data in myactivity.
The second requires a look at the configuration of the Intentfilter in the androidmenifest.
Copy Code code as follows:

<intent-filter>
<action android:name= "Android.intent.action.VIEW"/>
<action android:value= "Android.intent.action.EDIT"/>
<action android:value= "Android.intent.action.PICK"/>
<category android:name= "Android.intent.category.DEFAULT"/>
<data android:mimetype= "Vnd.android.cursor.dir/vnd.google.note"/>
</intent-filter>
<intent-filter>
<action android:name= "Android.intent.action.VIEW"/>
<action android:value= "Android.intent.action.EDIT"/>
<action android:value= "Android.intent.action.PICK"/>
<category android:name= "Android.intent.category.DEFAULT"/>
<data android:mimetype= "Vnd.android.cursor.dir/vnd.google.note"/>
</intent-filter>

This is configured to use the action, data, category these things, so smart you must think intent will have these things, and then a match does not find the receiver? The action is actually a string name of intent.
The above Intent-filter configuration file shows that the activity can accept different Action, of course, the corresponding program logic is not the same, mention the mimetype, he was defined in ContentProvider, If you realize a contentprovider on your own, you must specify MimeType in order for the data to be used by others. Do not know the principle of white did not, summed up a sentence, is that you call another interface is not directly new that interface, but by throwing out a intent, so that the system to help you to call that interface, so how loose Lotus ah, but also in line with the life cycle is the principle of system management. Want to know what category is, what Android does for you, and so on, please visit the official link personally Intentps: Students who want to know how to call the system application can take a closer look at your logcat, Do you have some information each time you run a program, such as:
Starting Activity:intent {action=android.intent.action.maincategories={android.intent.category.launcher}flags= 0x10200000comp={com.android.camera/com.android.camera.gallerypicker}}
Then the intent of some of the set method, you know how to call it, I hope you like:
Add
1. ListView How do you optimize it.
2. View refresh, said before.
3. IPC and principle.
4. Android Multithreading.
5. Why does Android have to design 4 components, the connection between them, not design lines (mainly to achieve the MVC pattern, but the most difficult model in Java is this, few products can do this model well.
6. Service cycle, activity cycle, talk about your Android internal application, such as his phone, and contacts and so on applications. The framework layer has a lot of things to look at, familiar with how Android does, whether you are doing application development or application framework layer development is very good. In your project experience, highlight what difficulties you encounter, and then how to solve! Try to highlight each technical point, of course, the interviewer sometimes in order to reflect whether you really did, he will ask you, you in this application to do that module, how many classes and so on. Occasionally, some interviewers will ask you if you've ever used a unit test from Android. Of course, I interviewed a lot of units, some do tablets, mobile phones, digital TV, some have to make a client such as ERP and so on, out of the front of the three, is basically all Android to get rid of, if you really want to do Android, we have to learn a lot. In short, a word, what kind of interviewers have, to interview the time to do all the psychological preparation, whether it is the technology or the foundation are solid. A person's ability to talk is also important, in short, is not very standard Mandarin, at the very least you have to make people understand, and the interviewer to speak very thoroughly, so you get more opportunities to offer, talk about salary also have advantages ~ ~ Of course once a company's interviewer told me that technology is at the expense of money, as long as you have the ability , how much he would please.

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.