Sunday, August 7, 2011

[android-developers] Broadcast Receivers: Can they execute simultaneously or do they always execute consecutively?

Hi,

I have a little confusion with broadcast receivers. I have a broadcast
receiver which is triggered upon TIME_SET and TIMEZONE_CHANGED actions
(the code is given below). What I was wondering is, can
OnDateTimeChanged (see the code below) be triggered simultaneously
(and its execution overlaps) when both TIME_SET and TIMEZONE_CHANGED
actions are triggered or is one always going to be triggered after the
other? Based on some simple experiments I did, I got the impression
that the two executions of OnDateTimeChanged are triggered
consecutively with no time overlap but I cannot be 100% sure of this.
If anyone has an idea I'll be very happy.

<!-- Excerpt from manifest -->
<receiver android:name=".OnDateTimeChanged">
<intent-filter>
<action android:name="android.intent.action.TIME_SET"/>
<action android:name="android.intent.action.TIMEZONE_CHANGED"/
>
</intent-filter>
</receiver>


// Broadcast receiver class
public class OnDateTimeChanged extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
// Do some work here
}
}

BTW, both TIME_SET and TIMEZONE_CHANGED can be triggered when under
Settings - Date&Time you switch to the Automatic mode and this changes
both the time and the timezone.

-Ali

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment