Comparison of two ways of Android registration broadcasting

Comparison of two ways of Android registration broadcasting

1. Resident broadcast

Resident broadcast, when your application is closed, if there is a broadcast message, the broadcast receiver you write can also receive it,

His registration method is to register in androidmanifest.xml in your application. Generally speaking, this method is static registration

The following is a configuration example

2. Non resident broadcasting

When the application ends, the broadcast will naturally disappear. For example, you can register the broadcast receiver in oncreate or onresume in the activity

Uninstall the broadcast receiver in ondestory. In this way, your broadcast receiver will be a non-stationary one. This is also called dynamic registration.

For example, write a broadcast receiver that monitors the status of sdcard

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>