Android pen interview

Source: Internet
Author: User

Www.20.100.com
1. Check whether the process of Android DVM is the same concept as that of Linux.
DVM refers to the Virtual Machine of dalivk. Every android application runs in its own process and has
An independent Dalvik Virtual Machine instance. Every DVM is a process in Linux.
Is the same concept.
2. What is the function of EF files on the SIM card?
The SIM card file system has its own specifications, mainly to communicate with mobile phones, Sim itself can have its own operations
In the system, EF is used for storage and communication with mobile phones.
3. What are the features of Memory Management in the embedded operating system?
Webpage, segment, and segment pages, using MMU, virtual space, and other technologies
4. What is an embedded real-time operating system? Does the Android operating system belong to a real-time operating system?
An embedded real-time operating system can be accepted and provided at sufficient speed when external events or data are generated.
The processing result can control the production process or quickly respond to the processing system within the specified time,
And control all real-time tasks to coordinate consistent operation of embedded operating systems. Mainly used for industrial control, military equipment, aviation
Air flight and other fields have strict requirements on the system response time, which requires the use of real-time systems. It can also be divided into soft real-time
Android is based on the Linux kernel, so it is soft real-time.
5. How many bytes does the longest Short Message count?
70 Chinese characters (including punctuation marks), 160,160 English bytes
6. What are the features and differences of animations in Android?
Two types: tween animation and frame animation. Tween animation. This method can be used.
Allows view components to move, zoom in, zoom out, and change transparency. Another Frame Animation is a traditional animation.
This method is achieved through sequential playback of arranged images, similar to movies.
7. Handler mechanism Principle
Andriod provides handler and logoff to satisfy inter-thread communication. Handler first-in-first-out principle.
The logoff class is used to manage message exchange between objects in a specific thread ).
1) Logoff: A thread can generate a logoff object to manage messages in this thread.
Queue ).
2) handler: You can construct a handler object to communicate with logoff so that new messages can be pushed to the message.
Or receive messages from the message queue.
3) Message Queue: used to store messages placed by threads.
4) thread: the UI thread is usually the main thread, and Android will create
Message queue.
8. Let's talk about the principles of the MVC model and its application in Android
MVC (model_view_contraller) "model _ view_controller ". MVC applications are always composed of these three parts
. Event causes the Controller to change the model or view, or change both. As long as the Controller
The data or attributes of models are changed, and all dependent views are automatically updated. Similarly, as long as the Controller
If the view is changed, the view will retrieve data from the potential model to refresh itself.
Www.20.100.com
View repainting and Memory leakage seem to be frequently asked questions during interviews.
1. Refresh View:
Use handle. sendmessage to send messages where refresh is needed, and then in the getmessage of handle
Execute invaliate or postinvaliate.
2. GC Memory leakage
Cause:
1. The database cursor is not closed
2. When constructing the adapter, the cache contentview is not used
Derivative listview optimization problem ----- reduce the object for creating a view and make full use of contentview. You can use
A static class to optimize the getview processing process/
3. Use recycle () to release the memory when the bitmap object is not in use
4. the lifecycle of objects in the activity is greater than that of the activity.
Debugging method: ddms ==> heapszie ==> dataobject ==> [total size]
There are other questions. You are welcome to raise this question. It can be the overall architecture and the Hal layer.
This article involves the following content:
Lifecycle of an activity
2. Change activity to a window: Activity attribute setting
3. What should I do if your background activity is recycled by the system: onsaveinstancestate?
4. call and call: our communication messenger-Intent
Lifecycle of an activity
Like applications on other mobile platforms, the lifecycle of Android applications is under unified control.
That is to say, the fate of the application we write is in the hands of others (systems). We can only
Learn and adapt to it.
To put it simply, why is this: When a mobile phone runs an application, it is possible to make incoming calls
The program will be interrupted when text messages are sent or no electricity is available, and the basic functions of service calls will be prioritized,
In addition, the system does not allow you to occupy too many resources. At least ensure the phone function, so when resources are insufficient
It may be killed. To put it bluntly, the following code shows the basic lifecycle of an activity:
Java code
Public
Class myactivity extends activity {
Protected
Void oncreate (bundle savedinstancestate );
Protected
Void onstart ();
Www.20.100.com
Protected
Void onresume ();
Protected
Void onpause ();
Protected
Void onstop ();
Protected
Void ondestroy ();
}
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 activities you write will reload these methods as needed. oncreate is inevitable.
During normal startup, they are called in the order of oncreate-> onstart-> onresume.
The order is onpause-> onstop-> ondestroy, which is a complete life cycle,
Someone asked, the program is running and there's a call. What should I do? If the ticket is aborted
The status of each activity is full screen. For example, onpause-> onstop: onstart-> onresume when the activity is restored. if the activity is interrupted
In this application, if theme is translucent or dicent activity, it is only onpause.
Onresume.
The following describes in detail what the system is doing and what we should do:
Oncreate: Create an interface to initialize data.
Onstart: In this step, the user can see and cannot interact with each other.
Onresume: it becomes interactive with the user. (in the activity stack system, you can manage these
At the top of the activity, after running the pop-up stack, return to the previous activity)
Onpause: This step is visible but interactive, and the system will stop animation and other CPU-consuming tasks.
I already know from the above description that some of your data should be saved here, because the priority of your program at this time
Lower, may be withdrawn by the system. The data stored here should be read in onresume. Note:
Www.20.100.com
It takes a short time to do things in the method, because the next activity will not start until the method is completed.
Onstop: becomes invisible and overwritten by the next activity
Ondestroy: This is the last method called before the activity is killed. It may be that the external class calls finish.
To save space, you can use isfinishing () to determine how to temporarily kill it. If you have
Rotate a progress dialog online. Please drop the cancel in ondestroy. Otherwise, wait until the thread ends.
When the dialog cancel method is called, an exception is thrown.
Onpause, onstop, and ondestroy, all activities may be killed by the system in three states.
To ensure the correctness of the program, you need to write the code for the persistent layer operation in onpause (),
Storage capacity is stored on the storage medium (generally databases ). Problems arising from changes in the life cycle in actual work
There are also a lot of questions. For example, if your application starts a new thread and is interrupted, you need to maintain the thread,
Pause, kill, or roll back data, right? The variables and
Pay attention to some interface elements. Generally, I use the android message mechanism [handler, message ].
Handle the problem of multithreading and interface interaction. I will talk about this later, because these things are already very large,
I will share my thoughts with you later.
2. Change activity to a window: Activity attribute setting
Let's talk about it easily. Some people may want to develop an application that floats on the main interface of the mobile phone,
So very
Simply set the theme of the activity to be defined in androidmanifest. xml.
Activity
Local sentence:
XML Code
Android: theme = "@ Android: style/theme. Dialog"
Android: theme = "@ Android: style/theme. Dialog"
This makes your application pop up in the form of a dialog box, or
XML Code
Android: theme = "@ Android: style/theme. translucent"
Android: theme = "@ Android: style/theme. translucent"
It becomes translucent. The properties of similar activities can be found in the Android. R. styleable class.
In the androidmanifestactivity method, we can see that the attributes of all elements in androidmanifest. XML can be described
For more information, see Android. R. styleable.
The property name is described above. The specific value can be seen in Android. R. style. For example
"@ Android: style/theme. Dialog" corresponds to Android. R. style. theme_dialog, (Change '_' to '.' <-- Note:
This is the content of the article, not a smiley face) can be used in the description file, look for the corresponding class definition and description file
The system will understand.
Www.20.100.com
3. What should I do if your background activity is recycled by the system: onsaveinstancestate?
When one activity a in your program is running, it actively or passively runs another activity
B
At this time, a will execute
Java code
Public
Void onsaveinstancestate (bundle outstate ){
Super. onsaveinstancestate (outstate );
Outstate. putlong ("ID", 1234567890 );
}
Public void onsaveinstancestate (bundle outstate)
{Super. onsaveinstancestate (outstate); outstate. putlong ("ID", 1234567890 );}
B will come to a again after completion. There are two situations at this time: A is recycled, and B is not returned.
Received and returned
The oncreate () method must be re-called for the received a. The difference is that the oncreate () method is started directly with parameters.
Quantity
Savedinstancestate. If it is not recovered, it will be onresume.
Savedinstancestate is a bundle object. You can basically understand it as
Map object. You may use it in oncreate (). If oncreate () is started normally, it will not be available.
To determine whether it is empty.
Java code
If (savedinstancestate! = NULL ){
Long id = savedinstancestate. getlong ("ID ");
}
If (savedinstancestate! = NULL) {long id = savedinstancestate. getlong ("ID ");}
As in the official notepad tutorial, you are editing a note, which is suddenly interrupted.
Remember the ID of this note, and then you can extract the note based on this ID.
Integer. This also shows that your application does not need to be saved. For example, if your interface reads a list
Remember something special. Oh, maybe you need to remember the position of the scroll bar...
4. call and call: our communication messenger intent
Intent is the intention of intent. The application communicates with intent and makes a call,
Www.20.100.com
Come
All phones send intent, which is the essence of loose coupling of the android architecture and greatly improves the complexity of components.
For example, if you want to click a button in your application to call someone, it's easy to see the code first:
Java code
Intent intent = new intent ();
Intent. setaction (intent. action_call );
Intent. setdata (URI. parse ("Tel:" + number ));
Startactivity (intent );
Intent intent = new intent (); intent. setaction (intent. action_call );
Intent. setdata (URI. parse ("Tel:" + number); startactivity (intent );
Throwing out such an intention, the system will wake up the dialing program and make a call when it sees your intention. What
Read contacts, send text messages, and emails. You only need to throw intent. This part is really well designed.
Ah.
So what does intent tell the system who needs to accept it?
There are two methods to use intent. The first method is to directly describe which class is required to receive the Code as follows:
Java code
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 method is very obvious, directly specifying myactivity as the receiver, and passing some data to myactivity,
In myactivity, you can use getintent () to get the intent and data.
In the second method, you need to first check the intentfilter configuration in androidmenifest.
XML Code
<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"/>
Www.20.100.com
<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>
In this configuration, action, data, and category are used, so you must think of intent
Will there be these things, and then the recipient will not be found after a match?
Action is actually a string name of intent.
The preceding intent-filter configuration file shows that this activity can accept different actions.
The program logic is different. Let's mention the mimetype defined in contentprovider.
You can implement a contentprovider by yourself. You must specify mimetype to enable data to be used by others.
I don't know how it works. In summary, you call other interfaces instead of the new interface.
By throwing an intent, the system can help you call that interface. This is so loose and compatible
Life cycle is managed by the system.
Please visit the official website
Link intent
PS: If you want to know how to call the system application, you can take a closer look at your logcat and run one
Is there any information such:
Starting activity: Intent
{Action = Android. Intent. Action. maincategories = {Android. Intent. Category. launcher}
Flags = 0x10200000comp = {com. Android. Camera/COM. Android. Camera. gallerypicker }}
Compare some set methods of intent to know how to call them. Hope you like it :)
1. How do you optimize listview.
Ii. Refresh view, as mentioned earlier
Iii. IPC and principles
4. Multiple Android threads
5. Why do android need to design four major components? the connection between them is not feasible without design (mainly for implementation
The current MVC mode, however, is also the most difficult mode in Java. Few products can make this mode well.
[This is what the interviewer of Technicolor asks ])
6. Service cycle and activity cycle. Let's talk about your understanding of Android internal applications, such
And contacts. There are a lot of things on the framework layer, so you should be familiar with how Android works.
It is good for you to develop an application program or the application framework layer.
In terms of your project experience, highlight what difficulties you encounter, and then how to solve them! Highlight every technical point as much as possible
Obviously, the interviewer sometimes asks you whether or not you have actually done so in this application.
Module, how many classes are used, and so on.
Occasionally, the interviewer will ask you, if you have used the unit test that comes with Android, how can you use it?
Of course, I have interviewed many companies, such as tablets, mobile phones, digital TVs, and ERP.
For the first three, basically all android is removed.
Www.20.100.com
You have to learn a lot.
In a word, there are all kinds of interviewers, and all psychological preparations should be made when you go to the interview, regardless of skill.
Skills and foundations are solid. A person's ability to talk is also very important. In short, it is not a very standard Mandarin, at least
What you say is understandable to others, and you have to thoroughly explain the interviewer, so that you have a larger chance To get an offer.
Salary also has advantages ~~ Of course, once an interviewer from a company told me that technology is free of money, as long as you have the ability,
He will pay for it.
Indeed, when I came to Beijing for a job, there were a lot of cattle, and some interviewers were very good.
Comments. Not every interviewer wants to embarrass you ~ The most important thing is to know your technology, because they also eat
The company is responsible for this.
1. How to refresh the view?
2. What is the difference between ddms and traceview?
3. What should I do if the activity is recycled?
4. How to introduce the C language in Java?
Answer
1. view can call the invalidate () and postinvalidate () Methods to refresh
2. ddms is a program execution viewer in which you can see information such as threads and stacks. traceview is
Program Performance Analyzer
3. The activity has been recycled, so there is only another one.
4. Java calls the C language program and can be implemented using the JNI Interface
The above answers are for reference only. After all, my personal abilities are limited, and I will inevitably answer the wrong answers .....
Answer:
1. View is refreshed by the system (there is a loop inside the system, monitoring events, business processing, and UI painting), you can use
Postinvalidate () prompts the system to refresh.
2. (I really don't know)
3. Please refer to the activity life cycle. If it is destroy by the system, that is to say, the recycle will only start from the new start.
Now
4. Call JNI. Read the Java Native Interface programmer's guide and
Specification, English version, from the sun website.

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.