Tuesday, 15 September 2015

android Intent.ACTION_BATTERY_CHANGED sticky?



According to:

http://developer.android.com/reference/android/content/Intent.html#ACTION_BATTERY_CHANGED

ACTION_BATTERY_CHANGED is a sticky intent.

But what is really sticky means?

I usually thought, sticky means after you got the reference you can keep use the reference and the android system will keep the date up in date.

I was wrong, you should keep call this every time to get new data: (otherwise you will always get the old data)


IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);

Intent batteryStatus = context.registerReceiver(null, ifilter);


No comments:

Post a comment