2

I have built a project from the existing samples of bluetooth chat for android 2.3 I am aware that the the emulator does not support bluetooth.

Earlier I was able to run the app on emulator. The functions didn't work, but I was at-least able to see that its running. I could see the user-interface and all.

But all of a sudden, today when I was trying the same app , I get an error saying bluetooth is not available and it quits.

I don't know if any settings have changed in eclipse by mistake, but can somebody help me to make it work somehow.

Nickolaus
  • 4,785
  • 4
  • 38
  • 60
Vinay Potluri
  • 545
  • 1
  • 9
  • 23

1 Answers1

1

you must have been using an earlier SDK version of the app that didn't check for absense of bluetooth support in the system....

I'm running the 2.1 SDK version of the demo, and that has the check in there.

you have two options:

1) go and find the same demonstration code you used before for an earlier SDK,

2) go into the code (bluetoothChat class, onCreate() method) and comment out this code snippet:

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }

actually - if you just comment out the "finish();" line that should allow the app to keep running, while still showing the warning.

Julian Higginson
  • 547
  • 4
  • 12