Recommended: "2020 Android interview questions summary [Collection]"
1, Android dvm processes and Linux processes, Whether the application processes have the same concept
DVM Refers to the virtual machine of dalivk. Each Android application runs in its own process and has an independent Dalvik Virtual machine instance. And each DVM is a process in Linux , so It can be considered as the same concept.
2##、simWhat is the function of the card’s EF ##sim
The card’s file system has its own specifications, mainly for communicating with mobile phones, sim You can have your own operating system, EF is used for storage and communication with mobile phones3
, what are the types of memory management in embedded operating systems and what are their characteristics ?Page type, segment type, segment page, using
MMU,Virtual space and other technologies4
、What is embedded Real-time operating system, Android Is the operating system a real-time operating system??、 The embedded real-time operating system means that when external events or data are generated, it can accept and process them at a fast enough speed, and the processing results can control production within the specified time. Process or embedded operating system that responds quickly to the processing system and controls all real-time tasks to run in a coordinated manner. Mainly used in industrial control, military equipment, 5##、How much is the longest short message? byte? 中文70( Including punctuation ), English 160 bytes 6、 android# What are the types of animations in ##, and what are their characteristics and differences? Two kinds, one is Tween animation, and the other The kind is Frame animation. TweenAnimation, this implementation can make the view component move, enlarge, shrink and produce transparency changes; anotherFrame Animation, the traditional animation method, is achieved by playing the arranged pictures in sequence, similar to a movie. 7、handlerPrinciple of the mechanism andriod provides Handler and Looper To meet the communication between threads. Handler First in, first out principle. Looper class is used to manage message exchange between objects within a specific thread (Message Exchange). 8、Talking aboutmvc The principle of the pattern, its application inandroid MVC(Model_view_contraller)” Model_View _Controller”. MVCAn application always consists of these three parts. Event(Event)results in ControllerChange Model or View , or change both at the same time. As long as Controller changes the data or properties of Models, all dependent View will be updated automatically. Similarly, as long as Controller changes View, View will get data from the underlying Model to refresh itself. ViewRedrawing and memory leaks seem to be questions often asked in interviews Use where you need to refresh , handle.sendmessageSend message, and then inhandlegetmessage executes invaliate or postinvaliate. 2. GCMemory leak 一 Life cycle of Activity Platform The application is the same as Android## The life cycle of the # application is uniformly controlled, which means that the fate of the application we write is in the hands of others (system). We cannot change it, we can only learn and adapt to it. Let me briefly explain why this is the case: when our mobile phone is running an application ,, it is possible that there are incoming calls. When a text message is sent to the phone, or the battery is out of power, the program will be interrupted at this time and priority will be given to serving the basic functions of the phone. In addition, the system does not allow you to occupy too many resources. At least the phone function must be ensured,So when resources are insufficient, they may be killed. Closer to home, the basic life cycle of Activity is as follows: Java Code Written by yourselfActivity will be repeated as needed Containing these methods, onCreate is inevitable, in an Activity During normal startup, the order in which they are called is onCreate -> onStart ->onResume, in ActivityThe order when being killed is onPause -> onStop -> onDestroy , this is a Complete life cycle, but someone asked, a call came while the program was running, what should I do with this program? It's aborted. If the new Activity is full screen when it is aborted, then: onPause->onStop , when restoring, onStart->onResume , if the one who interrupts this application is a Theme is Translucent or Dialog ActivityThen it’s just onPause,when restoring onResume . Let’s introduce in detail what the system is doing and what we should do in these methods: two Let Activity become a window: ActivityProperty settings Let’s talk a little more relaxedly,Some people may want to make an application that floats on the main interface of the phone. , so it’s simple, you just need to set the theme of Activity Here is a sentence where Activity is defined in AndroidManifest.xml : . three When an Activity A in your program actively or passively runs another new one during runtime Activity B At this time A will execute JavaCode 四 Calling and being called: our messengerIntent SayIntent, IntentIt is this intention, Intent## A call. When a call comes, 再对照一下Intent的一些set方法,就知道怎么调用咯,希望你喜欢:) One, listviewHow did you optimize it? . 1.ViewHow to refresh?
#, aerospace and other fields have strict requirements on system response time, which requires the use of real-time systems . It can be divided into soft real-time and hard real-time, and android is based on linux Kernel, so it is soft real-time.
1)Looper: A thread can generate a Looper object, which manages the Message Queue(Message Queue in this thread ).
2)Handler: You can construct Handler Object to communicate with Looper so that push new messages arrive Message Queue; or receive Looper from Message QueueGet the message sent by ).
3) Message Queue(Message Queue): is used to store messages put by threads.
4) Thread: UI thread is usually main thread, and Android will create a # for it when it starts the program ##Message Queue.
1. Refresh View:
Occurrence:
1.cursor of the database Not closed
2.ConstructionadapterWhen,not using cachecontentview
derivative Optimization issues of listview-----Reduce creation view objects,make full use ofcontentview, You can use a static class to optimize the process of getview/
3. BitmapWhen the object is not in use, userecycle()Release memory
4. The life cycle of the object in activity is greater than activity
Debugging method: DDMS==> HEAPSZIE==>dataobject==>[Total Size]
二 Let Activity become a window: ActivityProperty settings
##三 Your backgroundActivityis blocked by the system
What to do with recycling: onSaveInstanceState
四 Call Invoked with: Our Messenger - Intent
一 The life cycle of Activity and other mobile phones 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();
}
onCreate:Create an interface here and do some data Initialization work
onStart:At this step, it becomes visible and non-interactive to the user
onResume:It becomes interactive with the user , (in activity the stack system manages these individuals through the stack Activity## At the top of #, after running and popping the stack, return to the previous Activity)onPause:
to This step is visible but not interactive. The system will stop animations and other things that consume CPU from the above description Already know that some of your data should be saved here,because at this time the priority of your program is reduced and it may be taken back by the system. The data saved here should be read out in onResume. Note: The time required for this method should be short, because the next activitywill not wait until this method is completed before startingonstop:
becomes invisible , overwritten by the next activityonDestroy: This is the last method called before activity is killed. It may be called by an external class finish method or the system temporarily kills it to save space, you can use isFinishing() To judge it, if you have a Progress Dialog turning in the thread, please check it in onDestroyCancel, otherwise when the thread ends, call Dialog# The cancel## method will throw an exception. onPause,onstop, onDestroy , in the three states activity may be killed by the system. In order to ensure the correctness of the program, you must onPause () Write the code for the persistence layer operation to save the user-edited content to the storage medium (generally are all databases). In actual work, there are many problems caused by changes in the life cycle. For example, if your application starts a new thread and is interrupted at this time, you still have to maintain that thread, whether to pause or kill it The data needs to be rolled back, right? Because Activity may be killed, so you must pay attention to the variables and some interface elements used in the thread. Generally, I use Android’s message mechanism [Handler,Message] to handle multi-threading and interface interaction question. I will talk about this later, because these things have become very popular recently, so I will share it with you after I clear my mind.
XmlCode
android:theme="@android:style/Theme.Dialog"
android:theme="@android:style/Theme.Dialog"
This will make your application pop up in the form of a dialog box, or XmlCode
android:theme="@android:style/Theme.Translucent"
android:theme="@ android:style/Theme.Translucent"
will become translucent,[Friendly reminder-.-]Similar to this## The properties of #activity can be found in android.R.styleable #AndroidManifestActivity As seen in the method, the introduction of the attributes of all elements in AndroidManifest.xml can refer to this class android.R.styleableThe above is the attribute name, the specific value is in android.R.style
You can see, for example, this"@android:style/Theme.Dialog"corresponds to android.R.style.Theme_Dialog ,('_'Replace with '.' <--Note: This is the content of the article, not the smiley face) can be used in the description file
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putLong(" id", 1234567890);
}
public void onSaveInstanceState(Bundle outState) {
B Will come back after completionA , There are two situations at this time, one is that A is recycled, the other is that it is not recycled and is ReturnReceivedA will have to be called againonCreate() method, different from direct startup, this time onCreate() has parameters. savedInstanceState, if it has not been recovered, it will still be onResume.
savedInstanceState is a Bundle object. You can basically understand it as a maintained by the system for you. MapObject. You may use it in onCreate(), if it starts normallyonCreateThere won't be it, so you have to check whether it is empty when using it.
JavaCode
if(savedInstanceState !=null){
long id =savedInstanceState .getLong("id");
}
if(savedInstanceState !=null){
Just like the official Notepad# In the situation in ##tutorial
, you are editing a certain note, if it is suddenly interrupted, then put the id of this note##Remember, when you get up again, you can use this id to change that note Take it out and the program will be more complete. This also depends on whether your application needs to save anything. For example, if your interface is to read a list, then there is no need to remember anything in particular, oh,
Maybe you need to remember the position of the scroll bar...
Intent will be sent, This is
Android
The essence of loose coupling of the architecture greatly improves the reusability of components. For example, if you want to click a button in your application to call someone, it is very simple. Take a look at the code first: Java
Code :Intent intent = new Intent();intent.setAction(Intent.ACTION_CALL) ;intent.setData(Uri.parse("tel:" number));startActivity(intent); Copy code
Throw such an intention, and the system will wake up the phone dialer after seeing your intention and make a call. To read contacts, send text messages, or emails, you just need to throw intent. This part is really well designed. Then
Intent#How to tell the system who needs to accept it What about him? There are usually two ways to use
Intent
. The first is to directly indicate which class is needed 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);#########Copy code############The first way is obvious, directly specify MyActivity as the recipient , and passed some data to MyActivity, in MyActivity You can use getIntent() to get thisintent and data.
The second option is to take a look at AndroidMenifest intentfilter is configured with
Xmlcode<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><p style="text-indent:21pt;"><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">这里面配置用到了</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">action, data, category</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">这些东西,那么聪明的你一定想到</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">intent</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">里也会有这些东西,然后一匹配不就找到接收者了吗?</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">action</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">其实就是一个意图的字符串名称。</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us"><br></span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">上</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;"> </span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">this section</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">intent-filter</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">The configuration file shows that this </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">Activity</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';"> can accept different </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us"> Action</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';"> , of course the corresponding program logic is also different</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">,</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">Mention that</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us"> mimeType,</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">It is defined in </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">ContentProvider</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">. If you implement one yourself</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">ContentProvider</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">You know, you must specify </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us"> mimeType</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';"> to allow the data to be used by others. I don’t know if the principle is clear. To sum up, you don’t call other interfaces directly</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">new</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">that interface, but by throwing a</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">intent</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">, let the system help you call that interface, this is so loosely coupled, and it conforms to the principle that the life cycle is managed by the system. If you want to know what </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">category</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';"> has, </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">Android</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';"> is pre-customized for you </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">action</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';">Whatever, etc., please visit the official link in person</span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">Intentps:</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';"> Students who want to know how to call system applications can take a closer look at your </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">logcat</span><span style="color:#000000;font-size:10.5pt;"><span style="font-family:'宋体';"> to see if there is some information every time you run a program, such as </span></span><span style="font-family:Verdana, 'sans-serif';color:#000000;font-size:10.5pt;" lang="en-us" xml:lang="en-us">:</span></p>
<pre class="brush:php;toolbar:false">Starting activity: Intent {action=android.intent.action.MAINcategories={android.intent.category.LAUNCHER}flags=0x10200000comp={com.android.camera/com.android.camera.GalleryPicker} }
two, Refresh of view, as mentioned before
##三,IPC##and principle
##Four, ##Android Multi-threading
#Five,AndroidWhy design4 Large components, the connection between them, can it be done without designing (mainly to realize the MVC pattern, However, the most difficult mode in java is also this. Very few products can do this mode well [ The interviewer at Technicolor asked this]) Six, the cycle of service, activity cycle, tell me about your Android# Understanding of internal applications, such as phone, and contacts applications. There are a lot of things in the framework layer, so it’s better to read more and be familiar with how Android is done. Whether you are doing application development or application framework layer development, it is very beneficial.
This is your project experience, highlighting the difficulties you encountered and how you solved them! Try to highlight each technical point. Of course, the interviewer will sometimes ask you questions such as which module you used in this application and how many classes you used to show whether you have actually done it. Occasionally, some interviewers will ask you, have you used the unit test that comes with Android, and how do you use it? Of course, I have interviewed many companies, some of which are making tablets, mobile phones, digital TVs, and some of which are making clients like erp, etc., out of the The first three are basically to change all the Android. If you really want to do Android, everyone still has a lot to learn. In summary In a word, there are all kinds of interviewers. When you go for an interview, you must be mentally prepared, whether it is technical or basic. solid. A person's conversational ability is also very important. In short, it is not very standard Mandarin. At least what you say must be understood by others, and you must make the interview The officer explained it very thoroughly, so you have a greater chance of getting an offer, and you will also have an advantage in negotiating salary~~ Of course, an interviewer from a company once told me that technology does not spare money, as long as you have the ability, no matter how much it is He invited them all.
2. What is the difference between DDMS and TraceView?
3. What should I do if my activity is recycled?
4.How to introduce # in Java ##C language?
Reference answer:1.View
can be called invalidate()andpostInvalidate()These two methods refresh2.DDMS
is a program execution viewer, in which you can see information such as threads and stacks, TraceView is the program performance analyzer3. activity
is recycled, then there is no choice but to start a new one 4.java
To call the C language program, you can use JNIinterface to implement
The above answer is for reference only. After all, my personal ability is limited. Well, it is inevitable that the answer will be wrong, haha...Answer:
1. View is subject to system refresh (there is a loop inside the system to monitor events and do business Processing, drawing UI), you can use postInvalidate() to prompt 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, In other words, the only way to recycle is to #start
4.Call via JNI. It is recommended to read "The Java Native InterfaceProgrammer's Guide and Specification", English version, from sunDownload the website.
The above is the detailed content of Baidu Android interview questions sharing. For more information, please follow other related articles on the PHP Chinese website!