简体   繁体   中英

Do I need to fill out the 'receiver' info in AndroidManifest.xml if I register a BroadcastReceiver dynamically?

Do I need to fill out the 'receiver ... /receiver' content in AndroidManifest.xml if I register a BroadcastReceiver dynamically using 'registerReceiver(mReceiver, pIntentFltr)' and unregisterReceiver(mReceiver). It seems like I don't need it.

No, you don't need it. The mechanisms complement each other, as stated in the documentation :

There are two ways to make a broadcast receiver known to the system: One is declare it in the manifest file with this element. The other is to create the receiver dynamically in code and register it with the Context.registerReceiver() method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM