Kumar's method might work, but you should look up
Context.bindService() and ServiceConnection.onServiceConnected()
to find out how to do this within Android's framework.

What I do: In MyApplication's
    @Override public void onStart()
I call:
bindService(new Intent(MyApplication.this, MyService.class),
    new (MyServiceConnection(this)),
    BIND_AUTO_CREATE);

MyServiceConnection implements ServiceConnection, and as soon as the
service is created or bound, you get a call to
MyServiceConnection.onServiceConnected(), which you implement like
this:
public void onServiceConnected(ComponentName name, IBinder service) {
    serv = ((MyService.LocalBinder)service).getService();
}
With serv being an instance variable of MyApplication of type
MyService which you can use to call methods of your Service. Hope this
helps.



On Mar 30, 1:26 am, T-Droid <[email protected]> wrote:
> Hi @all,
>
> I have a design problem with my Android components.
>
> My activity is starting a service which is doing the work in the
> background. What I want is that the service informs the activity about
> state changes. How can I do this?
>
> Normally I would add an observer but the activity has no reference to
> the service. Then I was thinking to take AIDL but this is more for
> inter-process communication.
>
> How is it possible that the service informs the activity about state
> changes? Both are running in the same process. What can you recommend?
>
> Thank you in advance.
>
> T-Droid

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to