Why Does Broadcastreceiver Need A Default Constructor?
I created a BroadcastReceiver which is constructed from a Service. The BroadcastReceiver needs to interact with the Service, so I pass this to the constructor. After adding the [Br
Solution 1:
It's is only required if you are registering BroadcastReceiver
using AndroidManifest
. Android uses reflection to instantiate the receiver and it needs a default constructor (otherwise, it doesn't know which arguments should be passed).
It looks like you are registering your broadcast receiver in code using Context.registerReceiver
. In this case you don't need to add receiver
tag in the AndroidManifest
Post a Comment for "Why Does Broadcastreceiver Need A Default Constructor?"