Android handlerr.removecallbacksandmessages (null) magical

Source: Internet
Author: User

Today in the Reading code found Android handlerr.removecallbacksandmessages (null) code in the Ondestory () call, before the use, that want to understand what to do, check the API:

Public final voidremovecallbacksandmessages(Object token)Added in API Level 1

Remove any pending posts of callbacks and sent messages whose obj are token . If token is null, all callbacks and messages would be removed.

This is the Google document interpretation, English is not good, please use Youdao translation,

Delete Whatever the pending post callback function and the obj token that sent the message.

Assuming the token is empty, all of the callback functions and messages will be deleted

Of course, this translation is not very accurate, meaning that when the number of parameters is null, all the callback functions and message are deleted

The advantage of this is that the memory leak can be avoided when the acticity exits

Android handlerr.removecallbacksandmessages (null) magical

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.