Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello,
We make UDP packets in android by this code:

byte[] sendData = new byte[1024];
sendData = ("namekey").getBytes();

DatagramPacket sendPacket = new DatagramPacket(	sendData, sendData.length, myBIp, PORT);


Now, I want send a key/value by that string.
How can I do it?
This code has error!
byte[] sendData = new byte[1024];
							
							Intent in=new Intent();
							in.putExtra("key", name);
							
							sendData=((String) in).getBytes();
Posted
Comments
Richard MacCutchan 7-Aug-15 12:31pm    
You cannot cast an Intent to a String. Spend some time learning the basics of Java before trying advanced programming.
suraty 7-Aug-15 12:49pm    
I know, I write it to say my desired.
Richard MacCutchan 8-Aug-15 3:25am    
Well it does not make any sense.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900