Calling startService() is not enough -- you need to have called
bindService() for the same intent, so the system had retrieved the IBinder
for it.  It needs to have been kept running.  This is useful for something
like background media playback, which has a published interface whiloe it is
running (and is in fact what it was added for), but perhaps little else. :}

On Thu, Jul 16, 2009 at 6:29 AM, Ola <[email protected]> wrote:

>
> 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.
>
> Cheers,
> Ola
>
> >
>


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