Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communication between two apps using emulator as server and client

I have a problem. I want to make an emulator on my computer as a server. Then I want to communicate to another application installed on another emulator on the same computer.Or this may be two phone also.similarly two emulator communicate as server client

I searched on Google but I found no relevant answers.

Problem:

1)I have two emulators or phone`

2)I want one work as server and the other to work as a client, and I want to communicate between them

like image 982
Tofeeq Ahmad Avatar asked Aug 12 '11 11:08

Tofeeq Ahmad


3 Answers

For 2 apps on the same virtual (or real) device to work together, besides the regular Intent object, you might have a look at bound Services and AIDL : http://developer.android.com/guide/components/aidl.html

like image 73
darma Avatar answered Oct 21 '22 16:10

darma


You can use this step if you connect your emulator with socket:

  1. run the first emulator as server
  2. telnet localhot 5554 from terminal
  3. redir add tcp:5000:6000
  4. run the second emulator as client
  5. input the ip from server and port

NB : tcp:5000:6000 is the port from server and client, 5000 is from client and 6000 as server port.

like image 31
dkriek Avatar answered Oct 21 '22 15:10

dkriek


If you want network connection between the two, you can do it, but each emulator is running behind its own virtual router. The 'Using The Emulator' documentation will help:

http://developer.android.com/guide/developing/devices/emulator.html#connecting

like image 27
FunkTheMonk Avatar answered Oct 21 '22 17:10

FunkTheMonk