There are two ways to use a BroadcastReceiver
, and you did not indicate which you are using.
One for a receiver registered by some other component -- like an Activity
-- via registerReceiver()
. This receiver will live for as long as it is registered, and so its data may last for more than one onReceive()
call. The component that registered the receiver would be responsible for persisting the data.
The other is to register your receiver in the manifest. Those, per the quoted passage in cdonner's answer, will go away after a single onReceive()
call. Your receiver will need to persist its data itself, to a database, flat file, or whatever.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…