Android class reference-Logoff

Source: Internet
Author: User

1. inheritance relationship

Java. Lang. Object

|____ Android. OS. Logoff

2. class overview

This class is used to return a message loop to the thread. By default, there is no message loop associated with the thread. Calling the prepare () method in the thread will run this loop, and the loop () method will process the message until the loop is terminated.

Most interactions with message loops are completed through the handler class.

The following is a typical example of the implementation of a message loop thread. It uses the prepare () and loop () Methods to sandwich the process of creating the initial handler object used for communication with Logoff:

Class
Looperthread extends
Thread {
Public
Handler mhandler;

Public
Void run ()
{
Logoff. Prepare ();

Mhandler
=
New handler ()
{
Public
Void handlemessage (Message MSG)
{

// Process incoming messages here
}
};

Logoff. Loop ();
}
}

3. Class description

Public Method

Void

Dump (printer PW, string prefix)

Synchronized static Looper

Getmainlooper ()

Return the main loop of the application, and the application will live in this main thread.

Thread

Getthread ()

Returns the Thread associated with the message loop.

Static void

Loop ()

Message queue in the running thread. Make sure to call the quit () method to end the loop.

Static Logoff

Mylogoff ()

Returns the logoff object associated with the current thread. If the thread is associated with a logoff object, null is returned.

Static messagequeue

Myqueue ()

Returns the messagequeue object associated with the current thread. This queue must be the queue called by the logoff object in which the thread is running. If an exception exists, an nullpointerexception type exception will be thrown.

Static void

Prepare ()

Initialize the current thread as a message loop. It provides an opportunity to create a processor to be referenced in a message loop before the message cycle is started. After calling this method, you must ensure that the loop () method is called and end the message loop by calling the quit () method.

Static void

Preparemainlogoff ()

Initialize the current thread as a message loop and mark it as the main thread of the application. Because the main message loop of the application is created in the android environment, we do not need to call this method.

Void

Quit ()

String

Tostring ()

Returns a brief string describing the object that outsiders can understand.

Void

Setmessagelogging (printer)

Control the log information processed by the logoff. If this function is enabled, log messages indicating the target handler object and message content will be written to the printer object at the beginning and end of each message distribution.

Parameter description:

Printer: A printer object that accepts log messages. If the parameter value is null, message logs are disabled.

 

The Inheritance Method is from Java. Lang. object.

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.