How to pass Remote Interface (aidl) throughout Activities ?
Posted
by Spredzy
on Stack Overflow
See other posts from Stack Overflow
or by Spredzy
Published on 2010-05-13T09:43:35Z
Indexed on
2010/05/13
9:44 UTC
Read the original article
Hit count: 216
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 ?
© Stack Overflow or respective owner