Android Face Test Essence

Source: Internet
Author: User

Reprinted from: http://blog.csdn.net/lmj623565791/article/details/24015867

The following topics are the landlord in the Android Communication group interview encountered, if you have a good topic or good opinion Welcome to share, the landlord will maintain this post for a long time.

High-level question for a company (2015-03-14) "Thank Helder for sharing"

1, detailed Android system architecture, including layer-to-layer call, binder, JNI, the underlying file read and write methods
2, describe one of their own project, asked to draw a structure diagram, UML diagram, detailed description of the project species of technical points, technical difficulties and solutions

3. An algorithm

4, talk about their own project management methods, the understanding of agile software development

Basic questions (2014-04-18)

1. Please explain the relationship between Message,handler,message Queue,looper in the single-threaded model.

Taking the main thread, 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 constantly

Remove the message from the MessageQueue and callback the 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 a maximum of 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 the Android, with the form is not related. Traditional in the web, in the form of writing file upload, in fact, the browser does

is to put 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.

3. What is the difference between memory overflow and memory leak? When will a memory leak occur? What are the methods of memory optimization?

Memory overflow The popular understanding is that the software (application) runs the required memory, exceeding its available maximum memory.

A memory leak is our use of a memory space that is not released after the use is complete.

Memory optimization: The part of Android that is prone to memory overflow is the loading of images, we can use the compression of images and the purpose of using LRUCache cache to control the memory that images can use.

There is also a timely shutdown of objects that are more resource-intensive, such as database Conn, various sensors, Service, and so on.

4. What scenarios are used in 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.

BUG: Asynctask maintains a thread pool of length 128, can execute 5 worker threads, and a buffer queue, when there are 128 threads in the thread pool and the buffer queue is full, if

When the task is submitted to the thread, Rejectedexecutionexception will be thrown.

Workaround: The call from a control thread to handle the asynctask determines whether the thread pool is full, or if it is full, then request Asynctask to continue processing.

5, Activity uses sharedpreferences to save data, the size has the wood to have the limit?

This really can't find ...

6. Are there restrictions on the size of data transfer between activity intent?

It looks like 40K.

7, Assest folder put files, for the size of the file there is no limit? 22

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.

At the same time, because you need a string path to get the file descriptor in this directory, the access speed will be slower. But putting some files in this directory will make things easier,

For example, copy a database file into system memory. Note that you cannot refer to files in the assets directory in the Android XML file, only through Assetmanager to access

These files. Database files and game data are better placed in this directory. In addition, the online information about assets and raw is stereotyped, so the single file

Error descriptions that cannot exceed 1M in size are also propagated, that is, if a file that reads more than 1M will be reported as "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 this statement wrote a demo, found that nearly 5 m of the compression package in assets and raw

Can be accessed normally, so correct it here, in theory, as long as the packaging does not exceed the size of the Android APK 50M limit is not a problem. Of course, not to rule out Android very early

The time for device hardware AAPT The two folder sizes at compile time, and if so, this should not be the case with newer versions of ADT.

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 the program there is a set of activity,

So the launcher will put the icon forward and put it on the main interface. When the user clicks on icon, a intent is issued:

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), at this time or construct a intent,startactivity.

The action in this intent can be 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

The difference is that the intent action from the icon's click is relatively single, jumping from the program or booting may be more of a style. The essence is the same.

9. Understanding of the affinity between programs.

1, by default, all activity of an app has the same affinity, is inherited from application, application affinity default is manifest package name.

2, affinity for the activity, like an identity card, you can tell the task in which they belong to one of them.

3. Application situation:

A: Select the appropriate host task for the activity according to Affinity;

B: In conjunction with the allowtaskreparenting attribute;

C: Start ACTIVITY use intent to set the flag_activity_new_task tag.

10, the same program, but different activity can be placed in a different 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 twice

2, set the activity android:configchanges= "orientation", the screen will recall the various life cycle, cut horizontal, vertical screen will only be executed once

3, set the activity android:configchanges= "Orientation|keyboardhidden", the screen will not recall the various life cycle, will only execute onconfigurationchanged method

12. What is the full name of Aidl? How does it work?

The full name is: 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. On Android, you

Adopt the 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

In one activity, access to an object in another service requires that the object be converted to a aidl identifiable parameter (possibly multiple parameters), and then used Aidl to pass these 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,

There are 2 things to do: 1. Introduction of AIDL related classes.; 2. Call the class generated by the Aidl.

How to create a aidl:

The 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.

Here are some of the data types supported by Aidl:

    1. Simple Java programming language types (Int,boolean, etc.) that do not require import declarations

    2. String, charsequence no special declaration required

    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.

(In addition: I did not try to Parcelables, compiled under the Eclipse+adt, but perhaps in the future will have some support

13, the process of DVM and the process of Linux, whether the process of the application is the same

The DVM process is the DALIVK virtual machine process, each Android program runs in its own process

Inside, each Android program system assigns him a separate Liunx uid (user ID)

Each DVM is a process within Linux. So, these two processes are a process.

Android Face Test Essence

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.