0

I would like to make bluetooth pairing on android, here is my code, it displays a message which tells if i want to pair my device with the other device B but only on my device.

Code:

String ACTION_PAIRING_REQUEST = "android.bluetooth.device.action.PAIRING_REQUEST";
Intent intent = new Intent(ACTION_PAIRING_REQUEST);
String EXTRA_DEVICE = "android.bluetooth.device.extra.DEVICE";
intent.putExtra(EXTRA_DEVICE, listDiscoveredDevices.get(0));
String EXTRA_PAIRING_VARIANT = "android.bluetooth.device.extra.PAIRING_VARIANT";
int PAIRING_VARIANT_PIN = 0;
intent.putExtra(EXTRA_PAIRING_VARIANT, PAIRING_VARIANT_PIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Thank you

Wooble
  • 87,717
  • 12
  • 108
  • 131
Bek
  • 261
  • 3
  • 11
  • can you give more explanation about what you are really trying – Sree Mar 31 '14 at 11:35
  • I want to make an application that do the bluetooth pairing of two mobile terminals. When I execute my code, it shows me the message pairing request on my mobile only, not in both devices. – Bek Mar 31 '14 at 11:39
  • some thing like this right http://stackoverflow.com/a/18133783 – Sree Mar 31 '14 at 11:42
  • Thank you, I tried it but doesn't work for me, it says : setPin(
    ) called but no native data available, ignoring. Maybe the PasskeyAgent Request was cancelled by the remote device or by bluez.
    – Bek Mar 31 '14 at 11:55
  • try this too http://stackoverflow.com/a/7934426 – Sree Mar 31 '14 at 11:59
  • It says that the device you are trying to connect to must have a socket created on listening mode. How can I do that? – Bek Mar 31 '14 at 13:14

0 Answers0