I am trying to pair one android device with another through the bluetooth. But its not getting paired,not even getting any error. Can anybody tell me what i am doing wrong here?
I have searched for the bluetooth
devices and displayed that into the list. And now I am trying to pair the selected device name with my device.
But its not getting paierd,its opening a dialog for taking the password and then it gets closed. Any help would be appreciated. Here is my code:
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id)
{
Log.i("Log", "ListItem is clicked at :"+position);
posn = position;
String str = (String) listViewDetected.getItemAtPosition(position);
Log.i("Log", "ListItem is :"+str);
bluetoothDevice=arrayListBluetoothDevices.get(position);
Intent intent = new Intent("android.bluetooth.device.action.PAIRING_REQUEST"); intent.putExtra("android.bluetooth.device.extra.DEVICE",bluetoothDevice); intent.putExtra("android.bluetooth.device.extra.PAIRING_VARIANT",0);
startActivityForResult(intent, 1);
}
I have declared the permission in the manifest file.
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />