Hi,
I have an Android Service running as a separate process.
When an Activity is launched , this activity connects to the service.
After successful connection to the serivce the *onServiceConnected *callback
is called.
So unitl this callback is called the activity should be blocked from making
any calls to the Service.
Now if I do a sleep in the Activity in order to wait till *onServiceConnected
*is called , *onServiceConnected *gets called after the sleep is over.
>From my observation it looks like *onServiceConnected* is getting called in
the same thread as the Activity.
So I am not able to block the Acitivity to make call to the Serive until
the it is successfully connected.
Is my observation correct or am I missing something wrong ?
Consider the AIDL
interface IAddService {
void addNos(int num1, int num2);
}
public class HomeScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
connection = new Connection();
Intent i = new Intent();
i.setClassName("android.service",
android.service.AddService.class.getName());
boolean ret = context.bindService(i, connection, Context.BIND_AUTO_CREATE);
**
*//Wait till onServiceConnected*
**
*addNos(1,2); //Not able to wait or syncronize until onServiceConnected is
called as the callback is getting called from same thread as the Activity is
running*
class Connection implements ServiceConnection {
public void onServiceConnected(ComponentName name, IBinder
boundService) {
service = IAddService.Stub.asInterface((IBinder) boundService);
}
}
Regards,
Sambhav
--
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