Android
Android

Reputation: 141

How to work with UDP in Android?

I am very new to the Android platform. I need to make a connection with a UDP server by using my Android UDP client. Now, I need to know how to work with UDP in Android. Please guide me to do this.

Upvotes: 7

Views: 13472

Answers (2)

Soumya Simanta
Soumya Simanta

Reputation: 11751

In my experience working with UDP on Android is similar to working with UDP on a normal Java application. Follow the example above and you should be okay. However, I would recommend that you do most of your testing on an actual device (if you have access to one) instead of the emulator. It took me some time to figure out that the emulator (at least the version I used) has a packet size limitation of about 8K.

Upvotes: 2

cristis
cristis

Reputation: 1995

You can work with UDP in Android applications just like in any Java app, with java.net.DatagramSocket and java.net.DatagramPacket. There's a short sample app available at http://www.anddev.org/udp-networking_-_within_the_emulator-t280.html

Upvotes: 9

Related Questions