-1

I am not more familiar with Android Bluetooth functionality. I have developed and working code of connect two Android device via Bluetooth thorough my app. Now the question is that. I have one profile in my app like user profile. Profile has name and picture of user only. Now let's take on example. I have two android device, First device has installed my app with profile name John. and second device has installed my app with profile name Lara. When I connect this two device through my app, If john connect with Lara than I want to show in my application (john's mobile) that John is connected with Lara. It's mean John app show that Lara profile. I have working code, connect two Bluetooth device through coding. But still I can't open paired device app profile name. I am finding the solution for this functionality for last two days, but Still I have not able to show profile in my app. I know that this question is not suitable for stack-overflow. but your answer help me a lot.

Thanks in advance.

Mohit Raval
  • 440
  • 1
  • 6
  • 19

1 Answers1

1

I would use the answer from this question which will make you send at least one String from a device to the other. What you're looking for is too exhausting for an answer but this is a start. I will not straight up copy the answer I'm linking to because I think you should check it out and up-vote it if it helps you, but I will use some parts of it so you can see if this is what you're looking for.

Basically, you open up a socket between the devices.

BluetoothSocket socket = device.createRfcommSocketToServiceRecord(uuids[0].getUuid());
socket.connect();
//Creating objects to hold the output and input from the socket
outputStream = socket.getOutputStream();
inStream = socket.getInputStream();

You then set up a function to write from one device to the other.

public void write(String s) throws IOException {
    outputStream.write(s.getBytes());
}

And, to read the string on the other device, you use a byte-buffer and translate it to a String. This is how you get the bytes.

bytes = inStream.read(buffer, bytes, BUFFER_SIZE - bytes);
Community
  • 1
  • 1
pimmen
  • 402
  • 4
  • 17
  • thank you for your cool reply, I am working on same coding structure. If I get success than I will upload my code here. Thanks again. – Mohit Raval May 19 '15 at 08:41