registerReceiver() with your IntentFilter and a null BroadcastReceiver to get the last-broadcast IntentHi,
There seem to be another way of getting the last broadcasted event:
You can callregisterReceiver()with yourIntentFilterand anullBroadcastReceiverto get the last-broadcastIntent
This approach is working for me.
But i would like to check on:
(1) whether this is an acceptable approach?
(2) whether this needs any un-registration?
(3) does it have any memory leak??
Thanks & Regards,
Sunita.
On Tue, Jan 18, 2011 at 1:34 PM, RupaSunita n <rupasu...@gmail.com> wrote:
Hi,
I'm using broadcast receiver to get notifications for HW status (attach/detach).
During application suspend/resume, the intent state and hence the HW state is lost from the app, hence the feature is not working once it resumes.
the application is not caching the last value before going to suspend state.
Is there any interface in BroadcastReceiver to read the latest sticky state??
I'm exactly looking for, how to use this below statement
"stickyBroadcasts are broadcasts whose data is held by the system after being finished, so that clients can quickly retrieve that data without having to wait for the next broadcast. "
current options i have in hand are:
(1) unregistering and re-registering on suspend/resume
(2) using local variables to remember the state (this may not be a complete fix)
Thanks & Regards,
Sunita.
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
registerReceiver() with the IntentFilter and a null BroadcastReceiver to get the last-broadcast IntentregisterReceiver() with the IntentFilter and a null BroadcastReceiver to get the last-broadcast IntentI think you are misunderstanding what sticky broadcasts are. I
suggest you re-read the BroadcastReceiver documentation, paying
particular attention to the commentary on sticky broadcasts. When you
register, you are told what the most recently broadcast status is.
Just remember that data -- it correctly describes the status until you
actually receive a new broadcast.
> This is required because my app was suspended for some time during which i
> dont know what happend to hw state.
> Thats why, on resume call i would like to know the last braodcasted state, i
> cant wait for next broadcast. Hope i'm clear now.
When you say your app "was suspended," does that mean that it has
unregistered its broadcast receiver? Or are you just talking about
the normal pause/resume Activity lifecycle?
If you have actually unregistered your broadcast receiver, then it's
true that you will not see a notification of the hardware state
change. When your application registers its broadcast receiver again,
however, you will get a copy of whatever state change intent was most
recently broadcast, even if that happened while your application was
shut down. That is what sticky broadcasts are *for*.
--
christopher tate
android framework engineer
On Wed, Jan 19, 2011 at 7:04 AM, RupaSunita n <rupasu...@gmail.com> wrote:
> Thanks Dianne and Frank.I think you are misunderstanding what sticky broadcasts are. I
>
> Hi Dianne,
> yes I'm getting the onReceive notification everytime the state is changed.
> But my requirement is to get the status in between two broadcasts.
> you can ask why do i need in between two broadcasts?
suggest you re-read the BroadcastReceiver documentation, paying
particular attention to the commentary on sticky broadcasts. When you
register, you are told what the most recently broadcast status is.
Just remember that data -- it correctly describes the status until you
actually receive a new broadcast.
When you say your app "was suspended," does that mean that it has
> This is required because my app was suspended for some time during which i
> dont know what happend to hw state.
> Thats why, on resume call i would like to know the last braodcasted state, i
> cant wait for next broadcast. Hope i'm clear now.
unregistered its broadcast receiver? Or are you just talking about
the normal pause/resume Activity lifecycle?
Sunita --> No, the app didn't unregister for broadcasts. It is just going to suspend state, in which state
it can't service any onReceive calls (it means all the broadcast events are missed).
Since anyway it is not processing onReceive calls, do you recommend me to unregister while suspending??
and re-register on resume??
Is there anyway to handle this without un-registering while suspending? This is what my original question.
--