Android Interview questions

Source: Internet
Author: User
Tags message queue


How do I handle multiple types of entries in a ListView?
What happens if there is a button inside the entry? How to deal with?
What happens if there is a checkbox in the entry, and how do I fix it?

Note: The interviewer said that the three issues have been developed experience should have encountered.

Answer:

Will the list view project lose focus?

Will grab the spotlight. You need to set a property in XML that begins with D,

By default, the sub-class control is clicked, and setting desc*****=blok**** overrides the focus of the child control.

1. Please explain the relationship between Message,handler,message Queue,looper in the single-threaded model.   takes the main thread to say that the main thread starts by invoking the Looper.prepare () method, Initializes a looper, puts it into threadlocal, and then calls Looper.loop () to traverse the message Queue continuously,   The creation of handler relies on the looper in the current thread, and Looper.prepare () must be called if the current thread does not have looper. Handler, SendMessage to Messagequeue,looper continuously   remove messages from MessageQueue, callback Handlemessage method.  2, if there is a 100M large file, you need to upload to the server, and the server form form can only upload 2M, what method to use.   This question is not very clear I think, first of all, the use of HTTP protocol upload data, especially under Android, with the form is not related. Traditional in the web, in the form of file upload, in fact, what the browser does   is to make our data parsing group into a string, to stream the way to the server, and upload the file with the Post method, post way to size no limit.   Back to the topic, it can be said that each time really can only upload 2M, then we can only truncate the file, and then uploaded separately. What is the difference between  3, memory overflow, and memory leaks? When will a memory leak occur? What are the methods of memory optimization?   Memory overflow Popular understanding is that the software (application) runs the required memory, exceeding its available maximum memory.   Memory leaks are our use of a memory space that is not released after the use is complete.   Memory Optimization: The easy Memory overflow part of Android is the loading of images, we can use the compression of images and use the LRUCache cache to control the memory that the picture can use.   also has a timely shutdown for resource-intensive objects such as database Conn, various sensors, Service, and more. What scenes are used in  4 and asynctask? What is its flaw? How to solve? The scenario that  asynctask uses is that we need to take some time-consuming actions, update the main thread when the operation is complete, or update the UI of the main thread during the operation.   Defect: A thread pool of length 128 is maintained in Asynctask and can be executed5 worker threads, there is a buffer queue, and when the buffer queue is full when there are 128 threads in the thread pool, Rejectedexecutionexception will be thrown if   submits the task to the thread at this time.   Resolution: The call from a control thread to handle asynctask determines whether the thread pool is full, or if it is full, then request Asynctask to continue processing.  5, activity with sharedpreferences to save data, the size of wood restrictions?   This really can't find ... Is there a limit to the size of data passing through intent between  6 and activity?   seems to be 40K.  7, Assest folder put files, for file size there is no limit? The  assets directory is more like an appendix type directory, Android does not generate an ID for the files in this directory and is saved in the R class, so it is less compatible with some classes and methods in Android.   Also, because you need a string path to get the file descriptor in this directory, the access will be slower. But putting some files in this directory will make it easier to do something,   copy a database file into system memory, for example. Note that you cannot refer to the files in the assets directory in the Android XML file, only through Assetmanager to access the   files. Database files and game data are better placed in this directory. In addition, the online information about assets and Raw is the same, so the single file   size can not exceed 1M * * ERROR * * Description is also spread, that is, if read more than 1M file will be reported "Data exceeds Uncompress_data_ MAX (1314625 vs 1048576) " ioexception, but also derived a variety of solutions. Personally think there should be no such restrictions, in order to verify that this statement wrote a demo, found that nearly 5 m of the compression package in assets and raw   can access the normal, so here to correct, theoretically as long as the package does not exceed the size of Android APK 50M limit is not a problem. Of course, it is not ruled out that Android very early   time because of the device hardware reasons AAPT at the time of compiling the two folder size restrictions, if so, the newer version of ADT should not have this situation.   From: Http://my.eoe.cn/futurexiong/archivE/5350.html  8, start a program, you can click on the main interface icon to enter, you can also jump from a program in the past, what is the difference between the two?   is because the launcher (the main interface is also an app), found in this program there is a setting of <category android:name= "Android.intent.category.LAUNCHER"/> Activity,   So this launcher will put the icon forward and put it on the main interface. When the user clicks on icon, a Intent is emitted:  intent Intent = Mactivity.getpackagemanager (). Getlaunchintentforpackage (PackageName );  mactivity.startactivity (Intent);   Jump past can jump to any allowed page, such as a program can be downloaded, then the actual download page may not be the homepage (also may be the homepage), then the construction of a intent,startactivity.   The action in this intent is possible with a variety of view,download. The system will select the program or page that can be opened for your intent according to the function that the third party program registers with the system. So the only point   difference is that the intent action from the icon's click is relatively single, jumping from the program or booting may be more styles. The essence is the same. Understanding of the affinity between  9 and programs.  1, by default, all activity for an app has the same affinity, which is inherited from application, and application's affinity default is the package name of manifest. &NBSP;2, affinity for the activity, like an identity card, you can tell the task in which you belong to one of them.  3, Application:  a: According to Affinity re-select the appropriate host task for the activity;  b: In conjunction with the allowtaskreparenting attribute;  c: Startup ACTIVITY uses intent to set the flag_activity_new_task tag. &NBSP;10, the same program, but can different activity be placed in a different task task stack?  Can be placed in a different task. You need to set different affinity properties for different activity, and the intent that initiates the activity needs to include flag_activity_new_task tags.  11, the life cycle of the activity when the screen is switched.  1, do not set the activity of the android:configchanges, the screen will recall the various life cycle, cut across the screen will be executed once, cut the vertical screen will be executed two times  2, set activity android: configchanges= "Orientation", the screen will still recall the life cycle, cut horizontal, vertical screen will only perform once  3, set activity android:configchanges= "orientation |keyboardhidden ", the cut screen does not recall the individual lifecycles, only the Onconfigurationchanged method  12, what is the full name of Aidl? How does it work?   Full Name: Android Interface Define Language   in Android, each application can have its own process. The service is often used when writing UI applications. In different processes, how to pass the object? Obviously, cross-process memory sharing is not allowed in Java.   Therefore, the object can only be split into simple forms that the operating system can understand to achieve the purpose of cross-boundary object access. In Java EE, an RMI is used to pass objects by serialization. In Android, the   uses Aidl way. Theoretically aidl can pass bundles, actually doing it is rather troublesome.  aidl (Android Interface Description Language) is an excuse to describe the language; The compiler can generate a piece of code through the Aidl file, which achieves the purpose of two process internal communication processes through a pre-defined interface. If you need   to access an object in another service in one activity, you need to first convert the object to a aidl recognizable parameter (possibly multiple parameters) and then use Aidl to pass the parameters, at the receiving end of the message, using the   These parameters are assembled into the objects they need. Aidl's IPC mechanism is similar to COM or CORBA, and is interface-based, but it is lightweight. It uses a proxy class to pass values between the client and the implementation layer. If you want to use Aidl,   needs to complete 2 things: 1. Introduction of AIDL related classes.; 2. Call the class generated by the Aidl.  aidl method of Creation: The &NBSP;AIDL syntax is simple and can be used to declare an interface with one or more methods, or to pass parameters and return values. These parameters and return values are not of any type because of the need for remote calls.   Below are some of the AIDL supported data types:  1. A simple Java programming language type (Int,boolean, etc.)  2 that does not require an import declaration. String, Charsequence does not require a special declaration  3. List, map, and parcelables types, which contain data members that can only be simple data types, such as string other than the supported types.   (also: I did not try to Parcelables, compiled under Eclipse+adt However, there may be some support for  13, DVM, and Linux processes, whether the application process is the same concept   The DVM process is the DALIVK virtual machine process, each Android program runs in its own process, each Android program system will assign him a separate Liunx uid (user ID), Each DVM is a process within Linux. So, these two processes are a process.

Android Interview questions

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.