0

I have a background service running and I would like to use AIDL to be able to communicate with 3rd party apps . I experimented with an app communication using AIDL and it's working great .

my question is what if I want to communicate with another app, how do I filter which app is binding at the moment?

I have tried filtering with:

@Override
public IBinder onBind(Intent intent) {
    // TODO Auto-generated method stub
    Log.d("INTENT",intent.getDataString())
    return (new IpPortBinder(getApplicationContext()));
}

but it crashes, because intent.getDataString() is null for some reason. so which method should I use here?

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

You can filter the intents in the androidmanifest file of your service project. steps as below: 1) define the filter in service's manifest file.

<service android:name="com.x.y.servicename">
  <intent-filter >  
    <action android:name="getdata" />  
  </intent-filter>  
</service> 

2) while calling binding the service call the bindservice from the client app with this intent

            Intent i=new Intent();
            i.setAction("getdata");
            ret=actContext.bindService(i, AddServiceConnection, Service.BIND_AUTO_CREATE);

the step 2 can be called from instance definition of ServiceConnection in the activity code.

JVN
  • 239
  • 2
  • 16