Linktodeath Introduction to Android IBinder

Source: Internet
Author: User

First look at the official explanation:

    • The Linktodeath () method can be used to register a ibinder.deathrecipient with the IBinder, which would be called if its containing process goes away.

That is, after we have applied for a service binder through Systemservice, we can call this IBinder's Linktodeath function to register. You can register an object of type Ibinder.deathrecipient. Where Ibinder.deathrecipient is an embedded class defined in the IBinder class.Public abstract void linktodeath (ibinder.deathrecipient recipient, int flags) SINCE:API Level 1

Register the recipient for a notification if this binder goes away. If This binder object unexpectedly goes away (typically because its hosting process have been killed), then the given Ibind Er. Deathrecipient ' s deathrecipient.binderdied () method would be called.

You'll only receive death notifications for remote binders, as local binders by definition can ' t die without You dying a s well.

When the service process corresponding to this ibinder is exited abnormally, such as being killed, the system invokes the Binderdied function of the Deathrecipient class object that was registered with Linktodeath before the IBinder.

In the general implementation, the BP terminal will register Linktodeath, the purpose is to listen to the bound service exception exits, the general binderdied function is used to release some related resources.

Linktodeath Introduction to Android IBinder

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.