Hi,
I'm an Android newbie, and I'm developing an application that performs
REST calls. I'm using a service that executes the calls in background
and puts the results on a content provider. The requests are enquehed
by the service and performed one at a time in a worker thread. My
doubt is on how the service can send callbacks to the activities, to
communicate the start and the end of the call (so that the activities
know if the call was succesfull). While the service is performing a
call the displayed activity may change. My current approach for the
service is to entends the class binder, to call directly the methods
of the service from the activities (that binds on start and unbinds on
stop). The activities implements an interface with the methods void
onCallStart() and void onCallFinish(), and have an handler. The
methods of the service take as parameter the handler and the context
of the acrivity (e.g. public void searchReports(final int
latitude,final int longitude,final int radius,final Handler
handler,final Context context)), so that the callbacks are performed
in this way :
handler.post(new Runnable() {
public void run() {
((IMyRestActivity)
context).onFinishCall(result,message);
}
});
My questions are:
1) Passing the context of the activities in this way I'm leaking
memory?
2) If yes, what is the better approach to use to perform callbacks,
avoiding this problem?
Thanks in advance,
Iacopo
--
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