Android Development-Basic Concepts small Finishing (iv) for the interview of the small partners to prepare ~ ~

Source: Internet
Author: User
Tags message queue

Reprint Please specify source: http://blog.csdn.net/iwanghang/

I am participating in the CSDN 2016 blog Star selection, hope to get your valuable a vote ~
Http://blog.csdn.net/vote/candidate.html?username=iwanghang
Please vote for me, thank you ~ ~
If there is no CSDN account directly using the/qq/Weibo landing can vote ~ ~



during the period of organizing these concepts, forcing yourself to read a lot of others ' blogs is a rare process. Although, some of the content, it is difficult in professional, easy to understand and the length of the three choices, but I think such four basic concept blog, or can bring you a lost help. If you have any mistakes, you should correct them.



59.Android images are loaded asynchronously.

1, using multi-threading. The time-consuming operation is placed in a sub-thread until it gets the data and sends a message to the main thread to update the display in the main thread.
2, Asynctask. The async line loads the picture. For time-consuming operations such as loading a picture requires that you do not block the UI thread, you must use an asynchronous task. Asynctask is a simple and lightweight component that does not require the use of Thread+handler to implement asynchronous tasks.
3, LruCache. Caches a picture that has already been loaded.

60.Android cache policy.

Cache management methods are databases and files that are typically saved to sdcard. Database such as (SQLite) cache mode. Files such as. txt.
What must be said is, LruCache, Disklrucache. LRUCache only manages the storage and release of images in memory, and if the images are removed from memory, it is obviously time-consuming to reload the image from the network. In this, Google also provides a set of hard disk caching solutions: Disklrucache (not officially written by Google, but obtained official certification).
Introduction to Level Three cache, memory cache (get picture display from memory), local cache (not available in memory from SD card), network cache (downloaded from the network and saved to local and memory)

Attach Guo Shen Related blog post link: http://blog.csdn.net/guolin_blog/article/details/28863651

61.Android thread pool.

The basic idea of the thread pool is also the idea of an object pool, which opens up a memory space in which many (not dead) threads are stored, and the thread execution schedule is handled by the pool manager. When a thread task is taken from a pool, the threads object is pooled after execution, which avoids the performance overhead of repeatedly creating thread objects and saves system resources.
You can shutdow it off when you don't have to deal with it, and when we define a thread pool, we can reuse threads without having to open more threads, which is vital for our mobile development, and the more thread you open, the more memory your app consumes and the slower it gets. It is necessary to improve the reuse of existing threads.
Benefits of the thread pool:
1. Reuse threads in the thread pool to avoid the performance overhead associated with creating and destroying threads.
2, can effectively control the thread pool maximum concurrency, avoid a large number of threads due to each other to seize the system resources caused by blocking phenomenon.
3, can be simple management of the thread. and provides functions such as timed execution and specified interval loop execution.
Thread pools include: Newcachedthreadpool () cache thread pool, newfixedthreadpool () fixed thread pool, Newscheduledthreadpool () scheduled thread pool, Singlethreadexecutor single-Instance thread

62.Android Message Queuing model.

Android uses Looper, handler to implement the message loop mechanism, the Android message loop is for threads (each thread can have its own message queue and message loop).
In Android, Looper is responsible for managing thread Message Queuing and message loops. We can get the Looper object of the current thread through Loop.mylooper (), and the Looper object of the current process's main thread can be obtained through Loop.getmainlooper ().
A thread can exist (and, of course, not exist) a message queue and a message loop (Looper).
Activity is a UI thread that runs in the main thread, and the Android system creates a message queue and message loop (Looper) for activity when it starts.
The role of handler is to add messages to a specific (Looper) message queue and to distribute and process messages in that message queue. When constructing handler, you can specify a Looper object that is created with the looper of the current thread if not specified.

63.Android sorting algorithm.

1. Direct selection of the sorting. Divides the data into two regions, ordered and unordered areas. The order is sorted by selecting the smallest number from the unordered area and then inserting it to the end of the ordered area, resulting in a larger ordered area. Until the number in the unordered area is zero, the sort ends.
2, bubble sort. Adjacent to the two number 22 to compare, take from small to large description, bubble sort will sink the large number to the bottom, will be small to float to the top. So the bubbling argument gets its name.
3, direct insertion sort. Compare the number of keys that need to be sorted with the previously ordered data from forward to back, so that it is inserted into the appropriate position.
4, merge sort. The idea of dividing is divided into several groups to ensure that each group is ordered and then merged, and the sequence is ordered.
5. Quick Sort. Divide a sorted sequence into two parts, one of which is the dividing line, and one part is smaller than that of the dividing line, and the other part is larger than the data of the dividing line. Because of recursive thinking, the two sequences are sorted quickly until the data are ordered.
6, Hill Sort. Record increments to group, and then direct insert sorting within the grouping, as the increment decreases until the increment is reduced to 1 o'clock, i.e. the amount of data in each grouping is 1, at which point the sort ends.
7, heap sorting. The data structures in the form of trees are sorted, each of which is a fully binary tree. Heap sorting is divided into Dagen and small Gan, Dagen (Keng Gen) means that in a complete binary tree, the non-leaf nodes used are greater than or equal to (less than or equal to) their left and right child nodes (present). So the vertex of the heap is not the maximum number or the decimal. In this way we can use this property to take out the number of vertices of Dagen (Keng Gen) each time and form an ordered sequence.
Source: Summary of seven sorting Algorithms (Java): 1190000005753446

64.Android design mode.

1. Single case mode. Make sure that there is only one instance of a class, and instantiate it yourself and provide it to the entire system.
2, factory method mode. Defines an interface that is used to create an object, so that subclasses decide which class to instantiate, and the factory method defers the instantiation of a class to its subclasses.
3, abstract Factory mode. Provides an interface for creating a set of related or interdependent objects without specifying their specific classes.
4, template method mode. Defines a framework for an algorithm in an operation, and delays some steps into subclasses so that subclasses can redefine some specific steps in the algorithm without altering the structure of the algorithm.
5, builder mode. Separating the construction of a complex object from its representation allows the same build process to create different representations.
6, Agent mode. Provides a proxy for other objects to control access to this object.
7, prototype mode. Use the prototype instance to specify the kind of object to create and create a new object by copying the prototypes. The prototype pattern requires that an object implement an interface that can "clone" itself, so that a new instance can be created by copying an instance object itself. Thus, by creating a new object from the prototype instance, it is no longer necessary to care about the type of the instance itself, so long as the method of cloning itself is implemented, it is possible to acquire new objects through this method without having to create them through new.
8, intermediary mode. Encapsulating a series of object interactions with a mediator object, the mediator makes the objects do not need to be shown to interact with each other, which makes the coupling loose and can change the interaction between them independently. The advantages of the broker pattern proper use of the mediator pattern avoids over-coupling between colleague classes, making it possible to use the peer classes relatively independently. Using the mediator pattern, you can transform a one-to-many association between objects into one-to-one associations, making relationships between objects easy to understand and maintain. Using the mediator pattern, you can abstract the behavior and collaboration of objects, and be able to manipulate the interaction between objects more flexibly.
9, Command mode. Intent: Encapsulates a request as an object, which allows the client to be parameterized with different requests, to queue or log the request, and to support revocable operations. Motivation: Separate the "requesting objects" and "the objects receiving and executing these requests".
10, the responsibility chain mode. Enables multiple objects to have the opportunity to process requests, thus avoiding the coupling between the sender and receiver of the request. Link the objects to a chain and pass the request along this chain until an object has processed it.
11, Decoration mode. AKA Packaging (Wrapper) mode, the decorative mode extends the functionality of the object transparently to the client, and is an alternative to the inheritance relationship.
12, the Strategy mode. Define a set of algorithms that encapsulate each algorithm and allow them to be interchanged. The advantage of the strategy pattern is that you can dynamically change the behavior of the object.
13, adapter mode. Provide interfaces to customers based on the services provided by existing classes to meet customer expectations. The adapter mode is intended to change the interface of the source so that it is compatible with the target interface. The default adaptation is slightly different, and it is a mediocre implementation provided to facilitate the creation of a non-mediocre adapter class.
14, iterator mode. Provides a way to access individual elements in a container object without exposing the object's internal details.
15, Combination mode. Group objects into a tree structure to represent the ' part-whole ' hierarchy. The combined mode makes the user consistent with the use of individual objects and composite objects. Objects by implementing (inheriting) a uniform interface (abstract class), the caller is consistent with the operation of a single object and a composite object.
16, observer mode. Defines a one-to-many dependency between objects so that when each object changes state, all objects that depend on it are notified and updated automatically. The Observer pattern defines a one-to-many dependency that allows multiple observer objects to listen to a Subject object at the same time. When the subject object changes in state, all observer objects are notified so that they can automatically update themselves.
17, the façade mode. The external communication with a subsystem must be done through a unified façade object.
18, Memo mode. captures the internal state of an object without compromising encapsulation, and saves the state outside that object. This allows the object to be restored to its previously saved state. 19, visitor mode. Encapsulates certain operations that act on elements of a data structure, and it can define new operations that act on these elements without altering the data structure. The visitor pattern is the behavior pattern of the object. The purpose of the visitor pattern is to encapsulate some operations that are applied to a data structure element. Once these operations need to be modified, the data structure that accepts the operation can remain intact.
20, State mode. When an object's internal state changes to allow its behavior to change, the object looks like it has changed its class. State mode allows an object to change its behavior when its internal state changes. This object looks like it has changed its class.
21, Interpreter mode. Given a language, define a representation of his grammar and define an interpreter that uses that representation to interpret sentences in the language.
22, enjoy the meta-mode. Reusing objects that already exist in our memory, reducing the performance consumption of system-created object instances. Flyweight in boxing is the most lightweight, that is, "The fly level" or "rainfall level", where the choice to use the "enjoy meta-mode" of the free translation, because it is more reflective of the intention of the model. The enjoy meta mode is the structure mode of the object. The enjoy meta mode efficiently supports a large number of fine-grained objects in a shared manner. 23, bridge mode. Decoupling abstractions and implementations so that they can vary independently. The bridge model is intended to "decouple abstraction (abstraction) from implementation (implementation) so that they can vary independently".
Source: Android design mode: http://blog.csdn.net/banketree/article/details/24985607

65.Android virtual machine.

1, Dalvik virtual machine. Android 4.4 ago. JIT compiler instant compiler. Dalvik is optimized to allow instances of multiple virtual machines to run concurrently in limited memory, and each Dalvik application executes as a standalone Linux process, and a separate process prevents all programs from shutting down when the virtual machine crashes. In fact, every application is run as a single virtual machine and is not involved with other applications.
2, art virtual machine. After Android 4.4. AOT this pre-compilation. In the course of application installation, art has recompiled all bytecode into machine code. There is no need for real-time compilation during the application to run, only direct calls are required. Reduce the power consumption of mobile phones, improve the battery life of mobile devices, in the garbage collection mechanism also has a greater increase.

66.Android performance Optimization.

Performance optimization is designed to reduce the lag that most users perceive.
1, the layout is complex. Layout depth, complexity, and number of controls.
2, Memory jitter. Multiple graphs cause frequent GC, the GC operation in Android must suspend all remaining operations, and excessive GC will generate memory jitter, which can have a very large impact on system performance.
3, excessive drawing. The same point in a frame is repeatedly drawn multiple times, which causes unnecessary loss of the system and greatly wastes system resources.
Source: https://www.zhihu.com/question/30033704
4. Move time-consuming operations (such as network requests, database operations, or complex computations) from the main thread to a separate thread.
5, avoid the ANR. Do not perform heavy operations on the main thread (UI thread).
6, initialize the query operation in the thread. When the query operation is being processed in the background, the presentation data is not instantaneous, but you can use the Cursorloader object to speed up the interaction between the activity and the user. After using this object, your app will initialize a separate background thread for ContentProvider to query, and when the query is finished, it will return results to the activity that invoked the query.
7. If the initialization operation is time consuming, please show a welcome screen.
8, power consumption. Optimize network requests and data resolution.
9, traffic consumption. If you don't have an Internet connection, let your app skip network operations. When using traffic, prompt the user for a large resource download.
Source: Top Ten tips for optimizing Android app performance: http://mobile.51cto.com/abased-455556.htm



1, the foundation is very important. I believe we all have a deep understanding of this.
2, the project should be in-depth. Do not scratch the project, the person who has participated in the interview should have some experience.
3, the mentality is very important. As with the college entrance examination, the attitude of the interview is not good, it will affect the play.
4, the details determine success or failure. From the base to the project, this will be reflected.
5, insist on writing a blog. Although the interview to now, only one interviewer to read my blog, but blogging is really a good thing and no harm.
6, everything should pay attention to fate. Sometimes, some things, really want to see fate, so the heart to relax some, do not deliberately enlarge some pain.
7, pay always have a harvest, the crux of the problem is whether you persist long enough. Some have paid a lot of efforts of small partners, although also a stumbling, but eventually have a better result.
Source: 2015 Internet School Recruit summary-all the way: http://blog.csdn.net/ns_code/article/details/40408397







Reprint Please specify source: http://blog.csdn.net/iwanghang/



Welcome to mobile development enthusiasts to communicate
Shenyang or neighboring cities companies interested in developing Android, please contact me
Contact information

: Iwanghang
qq:413711276
Email: [Email protected]


Android Development-Basic Concepts small Finishing (iv) for the interview of the small partners to prepare ~ ~

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.