Android interview question 7

Source: Internet
Author: User

, And.

Obtains the objects in the current thread, which are used to extract from the stored objects and then distribute and process them.

Message Queue: Used to store published messages, usually attached to a thread that creates it. You can obtain the message queue of the current thread.

:You can publish or process one message or operation. by publishing a message, the message will only be sent to the Message Queue associated with the message queue, and can only process messages in the message queue.

:It is a bridge between communication and message queues. The program component first passes the message to and puts the message into the queue. The messages in the message queue are also broadcast to all: After receiving the message, the message is called for processing.

:Message type. A single message is obtained in the method in the class for processing. In the single-thread model, a message queue is designed for thread communication problems, the thread can combine and exchange information with components. They are described as follows:

Message, which is understood as information exchanged between threads. When the background thread for processing data needs to be updated, it sends some data to the thread.

The processor is the main processor responsible for sending and executing the content. The background thread is referenced by the passed object. This class is required to process the operation content, for example. It is usually required to subclass the implementation method.

A message queue is used to store published messages and run first-in-first-out.

There will be a corresponding. Messages are sent in either of the following ways: Or. Both messages are inserted at the end of the team and executed in FIFO order. However, messages sent through these two methods are executed in a slightly different way: an object will be processed by a function by sending it, and an object is sent through the method, it will be executed by itself.

Is the manager of each line. No, but will be automatically created for the main thread, but not in the Child thread. Therefore, the main thread is not called, but the current thread may be called. For the use of sub-threads, a correct method is provided: the general process of this mechanism:

After the method starts running, the non-ones in the method are retrieved cyclically in the receiving order.

In the beginning, all of them are. When it arrives, the property of the object set in this function is the current object. Then, the corresponding function is called for processing. In the method, how to deal with it is determined by the user, three judgments, the priority from high to low:

In it, an object that implements the interface, in which the function is used for processing;

It points to an object that implements the interface for processing;

The class corresponding to the processing message object inherits and implements the functions in it. The implemented functions process messages.

The method has the lowest priority!

After processing this, set this parameter to recycle it!

This thread is used to determine which thread the object belongs!

If the object's constructor parameter is null, it is the current thread;

The object of the main thread is obtained, and the object of the current thread is obtained.

What are the startup modes? What does it mean?

(Default ),,,.

: They can be instantiated multiple times and can be located in any stack. the initiator and the initiator are located in the same (unless

: If the current instance is at the top of the stack, it will not be created and called. If it is not on the top of the stack, a new instance is created. Mode.

: Only one instance is created.

What are the startup methods? What does it mean?





FLAG_ACTIVITY_SINGLE_TOP
If it is set, when this Activity is running at the top of the history stack, a new

FLAG_ACTIVITY_BROUGHT_TO_FRONT
This flag is not set by the program code. For example, the system helps you set the singleTask mode in launchMode.




FLAG_ACTIVITY_FORWARD_RESULT
If you set and use the Intent to start a new Activity from an existing Activity, the Activity that replies to the target will be uploaded to the new Activity. In this way, the new Activity can call setResult (int), and the result value will be sent to the Activity that is used as the reply target.

FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
This flag is generally not set by the application code. if the Activity is started from the history (usually press the HOME Key), the system will help you set it.





FLAG_ACTIVITY_NO_HISTORY
If this parameter is set, the new Activity will not be retained in the history stack. The Activity is closed as soon as the user leaves it. You can also set the noHistory feature.

FLAG_ACTIVITY_NO_USER_ACTION
If this parameter is set, when a newly started Activity enters the foreground, this flag will block onUserLeaveHint () from the previous Activity callback before the Activity is paused ().




Optimization Scheme

If the custom adapter is used, check whether the parameters passed in by the method are set. If the parameters are set, create and return them. If the parameters are not set, use them directly. Create as few as possible in this method.
To set () and input an object to cache the data to be displayed, which can achieve asynchronous loading of image data.
If you need to display a lot of data, you need to consider page loading. For example, if you want to display a total of items or more items, we can consider loading the items first and loading the following items when the user pulls them to the bottom of the list.

40. Differences between permissions for running a program and those for a file system

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.