I don't think the behavior of the broadcast has changed.  It is pretty
simple.  Here is the code from GB.  It is not ordered, so every registered
receiver will get it.

       private final void sendIntent(int headset, int headsetState,
intprevHeadsetState, String headsetName) {

        if ((headsetState & headset) != (prevHeadsetState & headset)) {

            //  Pack up the values and broadcast them to everyone

            Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG);

            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);

            int state = 0;

            int microphone = 0;


            if ((headset & HEADSETS_WITH_MIC) != 0) {

                microphone = 1;

            }

            if ((headsetState & headset) != 0) {

                state = 1;

            }

            intent.putExtra("state", state);

            intent.putExtra("name", headsetName);

            intent.putExtra("microphone", microphone);


            if (LOG) Slog.v(TAG, "Intent.ACTION_HEADSET_PLUG: state: "
+state+" name: "+headsetName+" mic: "+microphone);

            // TODO: Should we require a permission?

            ActivityManagerNative.broadcastStickyIntent(intent, null);

        }

    }

On Sat, Jan 8, 2011 at 4:59 PM, Jake Basile <[email protected]> wrote:

> I really doubt it's crashing, as the service doesn't do anything, really.
> It registers the BroadcastReceiver and then sits and holds a reference to
> it. It would sometimes get killed before, but it would then be restarted,
> re-register, and continue on.
>
> As it stands, the current code I have isn't getting it's onDestroy called,
> and if it is then restarted it's onStartCommand isn't being called either:
> this leads me to believe the service lifecycle isn't the problem. I think
> something is happening to the BroadcastReceiver somehow that is causing it
> to not receive the event.
>
> To be sure, I'm trying out the startForeground thing to rule out the
> service lifecycle issue. If that doesn't fix it I will check out the logs
> and your dumpsys call.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

Reply via email to