I'm having a problem using peekService(Context, Intent) from my
BroadcastReceiver to notify a Service of an event.

I have written a little application that sends an SMS and verifies
that it is sent. It is run as a Service, not an Activity, in order to
send text messages from the background. I have a BroadcastReceiver
that listens to the "Sms sent successfully" and "Sms delivered
successfully" intents that are broadcast when the message is sent and
delivered.

The messages are sent successfully and the BroadcastReceiver is then
triggered and it prints into the log when the message is sent and when
it is delivered. I however want the BroadcastReceiver to tell the
Service that the message is sent successfully, so the service knows if
it was successful. This is where the peekService method seems to be
suitable. I'm calling it from the BroadcastReceiver's onReceive
method, but peekService only returns a null IBinder, which obviously
is of no use to me.

The Service is still running and has not been destroyed. It is
sleeping for 15 seconds at 1-second intervals and printing that into
the log, waiting for the BroadcastReceiver to notify it of a sent
message.

The Intent I use in peekService is _identical_ to the one I used when
calling startService in the first place, so the intent should be
correct, since starting the Service worked.

There is sadly no useful log to paste here, all it does is prints that
my IBinder is null, a NullPointerException.

Some code (called from within BroadcastReceiver.onReceive:


Intent serviceIntent = new Intent();
serviceIntent.setComponent(new ComponentName("mypackages.services",
                "mypackages.services.Messages"));
binder = peekService(context,serviceIntent);

if (binder == null) Log.d(TAG, "binder == null");
else Log.d(TAG, "binder != null");


The log at the end shows "binder == null".

Cheers,
Ola

--~--~---------~--~----~------------~-------~--~----~
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