1

I'm pretty new to android app development and java, but I've been working on this project and have run into some problems. I connected a USB Bluetooth Dongle to my Raspberry Pi and the goal is to have my android app sense whenever I am in range of the Raspberry Pi. I know the MAC address of the dongle. All I really need to do is connect to it, but whenever I run the btSocket.connect(), I'm getting the catch. So here's my code so far.

BluetoothAdapter btAdapter =  BluetoothAdapter.getDefaultAdapter();
BluetoothDevice transmitter = btAdapter.getRemoteDevice("00:15:83:0C:BF:EB");
try {   btSocket = transmitter.createInsecureRfcommSocketToServiceRecord(MY_UUID);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    Log.d(getClass().getName(), "Creating socket failed");
   }
try {
    btSocket.connect();
} catch (IOException e) {
    // TODO Auto-generated catch block
Log.d(getClass().getName(), "Connection failed");
}

Here's the stack Trace since I cannot post images yet.

java.io.IOException: Unable to start Service Discovery
at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoohtSocket.java:455)
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:230)
at com.example.alarmservice.ScheduledService.onHandleIntent(ScheduledService.java:49)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.HAndler.dispatchMessage(Handler.java:89)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)

I'm also confused on how to know what to use for MY_UUID. Thanks for your help!

Schaab18
  • 31
  • 4
  • Print the stack trace, it will have more information on what went wrong. – thegrinner Jun 20 '13 at 18:33
  • I can post more of it if that wasn't enough. Tried to make it as simple since I had to type it. – Schaab18 Jun 20 '13 at 19:20
  • It seems this bug depends of your type of phone (every manufacture prepare your own implementation of BT software). Try to use this sollution: http://stackoverflow.com/questions/4444235/problems-connecting-with-bluetooth-android – Michał Rowicki Jun 20 '13 at 19:23

0 Answers0