accessing remote services functions

i ran into a problem with remote services. after i started and bound my service, i want/need to access it's functionality. this works just fine if i work with buttons and onclick-controllers just as in http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/RemoteServiceBinding.html

but actually, i need to access the services functions DIRECTLY after binding the service, like:

Intent intent = new Intent(IwlService.class.getName()); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);

String.valueOf(wlService.getDataFromService()); // this will CRASH the app!!!

if i access the service function "getDataFromService()" in an onClickListener, it works perfectly.

how do i access the services functions directly after binding/starting the service?

Answers


but actually, i need to access the services functions DIRECTLY after binding the service, like:

That is not possible. The service may need to start up, for example. In the case of a remote service, that will take a few hundred milliseconds.

how do i access the services functions directly after binding/starting the service?

You don't. You rewrite your code to access your service starting with the onServiceConnected() method in your ServiceConnection object. Any time before that and your service is not ready.


Need Your Help

How to use date and time received in a outlook mail in a event calender of outlook?

email events calendar outlook registration

Like Google calender, is it possible to make a functionality such that when some one register an event from website with date and time, then event will be added in an outlook event calender automat...

What is a third party cookie?

cookies facebook

What is a third party cookie and how is it used in Facebook connect feature?