0

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" />
Narendra Pal
  • 6,474
  • 13
  • 49
  • 85
  • help me to resolve this. – Narendra Pal Aug 30 '12 at 13:13
  • pls refer http://stackoverflow.com/questions/4989902/how-to-programmatically-pair-a-bluetooth-device-on-android & http://stackoverflow.com/questions/5885438/bluetooth-pairing-without-user-confirmation this seems to happen always – Athul Harikumar Aug 30 '12 at 13:30
  • I have seen but not getting any idea about this. Can you tell me how to this to achieve pairing – Narendra Pal Aug 30 '12 at 13:36
  • 1
    refer sample Bluetooth chat app available in android developers site – Athul Harikumar Aug 30 '12 at 13:38
  • As per my problem, i have posted right question. But why downvoted this? Can you suggest me?? – Narendra Pal Aug 31 '12 at 02:57
  • I have gone through the Bluetooth Chat application. But in that its not connection to my device.Please friends please suggest me any site through which i can pair my device programatically. – Narendra Pal Aug 31 '12 at 04:45
  • you cant actually pair your device programatically (as prior to 2.3.3 it was concidered a security flaw ) but from 2.0+ you can use unpaired rf socket to communicate. sry i dont feel sm1 can help you out in that any way try your luck – Athul Harikumar Aug 31 '12 at 04:49
  • please help me out guys. or else tell me any reference to do direct connection to the unpaired devices – Narendra Pal Aug 31 '12 at 08:50

1 Answers1

0

Here is an answer for you:

You may experiencing some Bluetooth chip errors. For example you tried to pair once with that device, failed for some reason, and then the chip will always decline repairing - although it shouldn't. It happened to me lots of times working with different Bluetooth Android phones...

What you can do: reset the Bluetooth chip.

Resetting the Bluetooth chip does not mean resetting your phone! While Android may be reset, the chip continues its normal lifecycle happily, and the error will reappear after reboot.

To make sure the Bluetooth chip is reset, take out the battery! On tablets, just empty the battery and restart.

If that still doesn't work, do a factory reset!

Bluetooth is a fragile technology, prone to bugs due to the ambiguity and vastness of its specs and the 'don't care' attitude of the chip manufacturers...

Radu
  • 2,076
  • 2
  • 20
  • 40
  • nope, I am not facing any of this kind of issue.That issue is solved simply.Now i have asked a new question regarding printing int this thread. http://stackoverflow.com/q/12257164/1395259 If you know the solution then pleaselet me know. – Narendra Pal Sep 04 '12 at 12:39