Android source code analytics Android toast using specific explanation toast yourself definition

Source: Internet
Author: User

During the Android development process. Toasts make it a class that we often use. When we need to communicate some information to the user, but it is not necessary to interact with the user, this approach is a very appropriate way.

we are accustomed to using toast like this: Toast . Maketext (Context context, String info, int duration). Show (); This method is

The system provides us with a convenient static method for creating toast objects, and the inside is still the relevant method of invoking the toast. Following

From its source code to the implementation of this class to do an analysis

In the Toast class, the most important show method for displaying the toast is called Service.enqueuetoast (pkg, TN, mduration);

The system maintains a toast queue for us, which is why two toasts are not displayed at the same time. This method will queue a toast and display the time that the system maintains the display.

private static Inotificationmanager Sservice;

Static private Inotificationmanager GetService () {if (Sservice! = null) {return sservice;        } Sservice = INotificationManager.Stub.asInterface (Servicemanager.getservice ("Notification"));    return sservice; The service Sservice is the service that the system uses to maintain the toast.
Inside the toast is another static Private class TN, which is the main implementation of the toast, which completes the creation of the toast view, and so on


Fa

Android source code analytics Android toast using specific explanation toast yourself definition

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.