0

I'm using this code:

Intent i = getApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

and as far as I understand i should be null if ACTION_BATTERY_CHANGED didn't occur, but it is never null and always returns me the same data. It worked fine when I used a broadcast receiver. Do I need to delete the Intent after receiving it?

Ehsan Mashhadi
  • 2,568
  • 1
  • 19
  • 30
user1566228
  • 119
  • 1
  • 7

2 Answers2

3

As soon as you register sticky intents will always deliver you last broadcasted data. So that is the reason you are always recieving data

nandeesh
  • 24,740
  • 6
  • 69
  • 79
1

Sticky=property of adhering result=which intent adhered with os called sticky intent

Normally you send broadcast a receiver using sendBroadcast(Intent) But When you are calling this method sendStickyBroadcast(Intent) it means that A broadcast Intent can be specified to be sticky in which case it will be retained by the system after it has been sent. But by default Intent.ACTION_BATTERY_CHANGED intent is sticky.

read the full post here http://iphoidtech.com/uncategorized/what-is-stcky-intent/

Ehsan Mashhadi
  • 2,568
  • 1
  • 19
  • 30