Android 无法连接到摩托罗拉Droid A855上的蓝牙

Android 无法连接到摩托罗拉Droid A855上的蓝牙,android,Android,我正在使用Android 2.1 sdk和Motorolad Droid A855型号,当尝试连接到蓝牙(Socket SPP)时,根据logcat,我得到以下错误:, 并在socket.conect()中获取异常抛出 这是我的密码 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); out = (Te

我正在使用Android 2.1 sdk和Motorolad Droid A855型号,当尝试连接到蓝牙(Socket SPP)时,根据logcat,我得到以下错误:, 并在socket.conect()中获取异常抛出

这是我的密码

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  out = (TextView) findViewById(R.id.out);

  // Getting the Bluetooth adapter

  BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  out.append("\nAdapter: " + mBluetoothAdapter);

   UUID uuid = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");

  if(mBluetoothAdapter==null) { 
   out.append("\nBluetooth NOT supported. Aborting.");
   return;

  }
  Log.i("BTDemo", ": "+ mBluetoothAdapter.isEnabled());

  if (!mBluetoothAdapter.isEnabled()) {
   Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
   startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
  }
  else
  {
   out.append("\nBluetooth Adapter Enabled"); 
  }

  try {

   BluetoothDevice devices=mBluetoothAdapter.getRemoteDevice("00:0E:6D:BA:89:F3");
   if(devices!=null)
   {

    socket = devices.createRfcommSocketToServiceRecord(uuid);
    Log.i("In Socket","Socket"+socket);
    Log.i("BTconnect", "Step 4");
   }
   else
   {
    Log.e("BTConnect","Bluetooth device is null");
    return ;
   }
   Log.i("BTconnect", "Step 5");

   // Listing paired devices
   out.append("\nDevices Pared:");
   //BluetoothDevice devices;
   Set<BluetoothDevice>  pairedDevices = mBluetoothAdapter.getBondedDevices();


   for (BluetoothDevice device:  pairedDevices) 
   {
    out.append("\nFound device: " + device);
   }

  } catch (Exception e) {

   e.printStackTrace();
  }

  try{
   if(socket !=null) // checking for socket is created or not
   {

    socket.connect();
    Log.i("BTconnect", "Step 6");
    Log.i("BTconnect", "Socket Connected");
    out.append("\n Socket Connected");
   }
   else
   {
    out.append("\n\n Socket is Null");
   }

  }catch(Exception e)
  {
   Log.i("BTconnect", "Step 7");
   Log.e("--------Inner Exception-----", "Socket not conncected");
   out.append("\n\n\n --------Inner Exception----- Socket not conncected");
   try {
    socket.close();
    out.append("\n\n  Socket closed");
   } catch (IOException closeException) 
   {
    Log.e("InitBluetoothDevice","while closing socket in catch block of connect()"+closeException.getMessage());
    out.append("\n\n --------Exception----- while closing socket");
   }

  }


 }

有人能帮我连接蓝牙吗?

知道发生了什么异常(确切地说)可能会帮助你找到问题的根源。但我无法在Mototola Droid A855中连接蓝牙,可以提供一些帮助。使用完全相同的代码,连接在2.1版本的三星I897上运行良好,在运行2.2版本的droid x上运行失败,在运行2.1版本的backflip上运行失败,在2.1版本的I100上运行失败,失败时的日志与下面发布的日志完全相同。所连接的设备没有区别。我已经在这个问题上纠缠了一段时间,还有典型的不兼容;(
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  out = (TextView) findViewById(R.id.out);

  // Getting the Bluetooth adapter

  BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  out.append("\nAdapter: " + mBluetoothAdapter);

   UUID uuid = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");

  if(mBluetoothAdapter==null) { 
   out.append("\nBluetooth NOT supported. Aborting.");
   return;

  }
  Log.i("BTDemo", ": "+ mBluetoothAdapter.isEnabled());

  if (!mBluetoothAdapter.isEnabled()) {
   Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
   startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
  }
  else
  {
   out.append("\nBluetooth Adapter Enabled"); 
  }

  try {

   BluetoothDevice devices=mBluetoothAdapter.getRemoteDevice("00:0E:6D:BA:89:F3");
   if(devices!=null)
   {

    socket = devices.createRfcommSocketToServiceRecord(uuid);
    Log.i("In Socket","Socket"+socket);
    Log.i("BTconnect", "Step 4");
   }
   else
   {
    Log.e("BTConnect","Bluetooth device is null");
    return ;
   }
   Log.i("BTconnect", "Step 5");

   // Listing paired devices
   out.append("\nDevices Pared:");
   //BluetoothDevice devices;
   Set<BluetoothDevice>  pairedDevices = mBluetoothAdapter.getBondedDevices();


   for (BluetoothDevice device:  pairedDevices) 
   {
    out.append("\nFound device: " + device);
   }

  } catch (Exception e) {

   e.printStackTrace();
  }

  try{
   if(socket !=null) // checking for socket is created or not
   {

    socket.connect();
    Log.i("BTconnect", "Step 6");
    Log.i("BTconnect", "Socket Connected");
    out.append("\n Socket Connected");
   }
   else
   {
    out.append("\n\n Socket is Null");
   }

  }catch(Exception e)
  {
   Log.i("BTconnect", "Step 7");
   Log.e("--------Inner Exception-----", "Socket not conncected");
   out.append("\n\n\n --------Inner Exception----- Socket not conncected");
   try {
    socket.close();
    out.append("\n\n  Socket closed");
   } catch (IOException closeException) 
   {
    Log.e("InitBluetoothDevice","while closing socket in catch block of connect()"+closeException.getMessage());
    out.append("\n\n --------Exception----- while closing socket");
   }

  }


 }
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sample.BT"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".BluetoothDemo"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="7" />

<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>
</manifest> 
09-07 06:24:14.077: VERBOSE/BluetoothEventRedirector(1649): Received android.bleutooth.device.action.UUID
09-07 06:24:14.077: DEBUG/BluetoothService(1098): Cleaning up failed UUID channel lookup: 00:0E:6D:BA:89:F3 550e8400-e29b-41d4-a716-446655440000
09-07 06:24:14.085: ERROR/--------Inner Exception-----(1769): Socket not conncected
09-07 06:24:14.085: WARN/System.err(1769): java.io.IOException: Service discovery failed
09-07 06:24:14.101: WARN/System.err(1769):     at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:377)
09-07 06:24:14.101: WARN/System.err(1769):     at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:201)
09-07 06:24:14.101: WARN/System.err(1769):     at com.sample.BT.BluetoothDemo.onCreate(BluetoothDemo.java:89)
09-07 06:24:14.101: WARN/System.err(1769):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-07 06:24:14.101: WARN/System.err(1769):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-07 06:24:14.101: WARN/System.err(1769):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-07 06:24:14.101: WARN/System.err(1769):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-07 06:24:14.101: WARN/System.err(1769):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-07 06:24:14.101: WARN/System.err(1769):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-07 06:24:14.101: WARN/System.err(1769):     at android.os.Looper.loop(Looper.java:123)
09-07 06:24:14.101: WARN/System.err(1769):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-07 06:24:14.101: WARN/System.err(1769):     at java.lang.reflect.Method.invokeNative(Native Method)
09-07 06:24:14.101: WARN/System.err(1769):     at java.lang.reflect.Method.invoke(Method.java:521)
09-07 06:24:14.101: WARN/System.err(1769):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-07 06:24:14.109: WARN/System.err(1769):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-07 06:24:14.109: WARN/System.err(1769):     at dalvik.system.NativeStart.main(Native Method)
09-07 06:24:14.249: INFO/ActivityManager(1098): Displayed activity com.sample.BT/.BluetoothDemo: 3640 ms (total 3640 ms)
09-07 06:24:16.874: VERBOSE/BluetoothEventRedirector(1649): Received android.bleutooth.device.action.UUID
09-07 06:24:18.046: ERROR/BluetoothEventLoop.cpp(1098): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1137/hci0/dev_00_0E_6D_BA_89_F3