Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 2 emulators communicating

I am new to android and want to create a simple game between 2 emulators.

Emulator 1 can send a string to emulator 2 and emulator 2 can send a string back to emulator 1.

Please can someone advise me on how to go about this as I have no idea.

Thanks.

like image 887
Tommy Avatar asked Feb 25 '11 14:02

Tommy


People also ask

Can android emulators connect to a network?

Android apps running in an emulator can connect to the network available on your workstation. However, apps connect through the emulator, not directly to hardware, and the emulator acts like a normal app on your workstation.

Can Android apps run on an emulator?

Android apps running in an emulator can connect to the network available on your workstation. However, apps connect through the emulator, not directly to hardware, and the emulator acts like a normal app on your workstation. This can cause some limitations:

Can emulated Android apps connect to a real device?

Finally, note that the pre-allocated addresses of an emulated device are specific to the Android Emulator and will probably be very different on real devices (which are also very likely to be NAT-ed, specifically, behind a router/firewall). Android apps running in an emulator can connect to the network available on your workstation.

What are the different types of Android emulators?

Android app and game developers like to test apps and games on as many devices a possible before launch. Usually the Android Studio emulator is fine for this kind of work. However, Xamarin and Genymotion are excellent for this type of use as well. The final main type is productivity.


2 Answers

To run 2 emulators at the same time, I would recommend running them both as virtual sessions (like in VMWare) and "bridge" the connections. Make sure you have static IP addresses for each VM.

As you're simply sending text between them, I would stick to HTTP at this stage just to get the proof-of-concept working. Just don't complicate your life too early. Http should be the easiest common denominator to work with for Wifi or Mobile carriers for now.

If you abstract the object model appropriately, you can later use other communication protocols by overriding the classes. The networking component should be transparent to the application.

like image 116
angryITguy Avatar answered Nov 09 '22 13:11

angryITguy


You can have direct communication using SMS (just use the emulator port number as phone number to test it) or Bluetooth. If you use Wifi or Mobile phone network, then you must have both devices connected to your server, you cannot have direct connection, or even if in some cases maybe you can, then you should not relay on this.

like image 39
JaakL Avatar answered Nov 09 '22 12:11

JaakL