1

I have the bluetooth device address I want to have variable transfer with ( I've use BluetoothAdapter to discover devices and ... )

Now I need an easy sample to use socket to send and receive variables... ( I need to use BluetoothSocket right ? )

I've seen Bluetooth Chat sample but I think many of it's codes are unusual for me, so I want to ask someone help me with an easy sample code to send an integer and receive a string easily, PLEASE.

I've checked bluetooth support and found device's bluetooth address before.

somethis like this I have :

BlutetoothAdapter mBluetoothAdapter;
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

string Address; // BluetoothAddress of wanted device saved into that
int IntToSend; // Integer I need to send

// HERE I need the codes to SEND MY INTEGER VARIABLE TO THAT DEVICE

// I NEED CODES TO LET ME SENT STRING FROM THAT DEVICE HERE

Can someone help me please ?


SOLVED : I've used this easy tutorial : http://manojprasaddevelopers.blogspot.com/2012/02/bluetooth-data-transfer-example.html

Because of low reputation I can't answer my question until next few hours, so I've edited my post. Anyway, Sorry If it wasn't a good question, please. :)


edit 2 : after all, used BluetoothChat sample, too... :)

Sina KH
  • 25
  • 1
  • 6
  • Sorry, What do you mean ? I've used listview to ask user select the device and now I need an easy code to send int and receive a string that will be sent from User's selected device. Could you help me please ? – Sina KH Jul 28 '13 at 09:48
  • if you already solved your case, you might help others by making another bluetooth tutorial with the proper layout (page) like this one: http://tsicilian.wordpress.com/2012/11/06/bluetooth-data-transfer-with-android/ Rather than the http://manojprasaddevelopers.blogspot.com/2012/02/bluetooth-data-transfer-example.html Which is very not comfortable to see (in user's eyes feeling). Good luck! :D – gumuruh Jul 07 '14 at 03:55
  • Refer this answer: https://stackoverflow.com/a/49746312/9405186 – Bhanu Prakash Pasupula May 08 '18 at 12:39

1 Answers1

0

(This question has been solved by the OP in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

I've used this easy tutorial : http://manojprasaddevelopers.blogspot.com/2012/02/bluetooth-data-transfer-example.html

Now SO deprecates URL only answers. The blog is quite lengthy and contains a large amount of code from another author and would be inappropriate to copy here. It contains 15 discrete code editing steps which involve create client and server codes which message each other.

Community
  • 1
  • 1
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129