0

I have implemented an android program with an activity and remote service. The activity is using AIDL to communicate and interact with the service but on a same machine and know that they use IPC mechanism to communicate with each other. Now, I want to put them on separate machines and make connection between them. I’m trying to use socket to make the connection but I don’t know how I can do it. How can I start/stop and bind the service, which is running on different machine from activity? The socket is the best choice for this case or there are other better solutions? Do I need to change the Binder class on the Android OS to handle this? I’d appreciate if you could help me to find the solution.

Thanks, Ra

Furniture Sell
  • 249
  • 3
  • 11

1 Answers1

2

How can I start/stop and bind the service, which is running on different machine from activity?

You don't.

The socket is the best choice for this case or there are other better solutions?

Direct device-to-device communications is generally not possible over the Internet, unless they are both on the same WiFi routing segment, due to NAT restrictions and the like. This is no different than the issues with direct PC-to-PC communications, with the added challenge that you typically do not control the firewalls involved. Most solutions involve using a server in the middle, acting as a broker or proxy.

Do I need to change the Binder class on the Android OS to handle this?

You need to not use Binder. Binder is IPC (inter-process communication), not RPC (remote procedure calls).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks.in http://developer.android.com/reference/android/os/Binder.html mentioned that i can "derive from Binder and implement my own custom RPC protocol" . – Furniture Sell Jun 09 '12 at 15:07
  • also i checked http://developer.android.com/reference/android/os/IBinder.html and binder class in android OS source code to see if it's possible to open socket in ontransaction() method and send the serialized obj over it or not (modify the ontransact() in android OS,compile OS,use the modified OS on the client and server).but before that i need to bind the service first and don't know if it'd be possible to open socket when it's trying to call bindservice in android os by changing the android os source code or not because it's not using ontransact() in this case. – Furniture Sell Jun 09 '12 at 15:09