Hi All,
I am developing an application using services and Remote interface.
I have a question about passing the reference of my Remote interface throughout Activities.
In my first Activity, I bind my service with my activity, in order to get a reference to my interface I use
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName arg0, IBinder service) {
x = X.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
// TODO Auto-generated method stub
}
};
x being the reference to my interface. Now I would like to access this interface from another activity, I see two ways to do it but I don't know which one is the "proper" way to do it :
- passing x with my intent when I call the new Activity
- redo
this.bindService(new Intent(y.this,z.class), mConnection, Context.BIND_AUTO_CREATE);
in the onCreate() of my new Activity
What would you advice me to do ?