【问题标题】:Problems with connecting bluetooth SPP in android?在android中连接蓝牙SPP的问题?
【发布时间】:2011-11-15 18:45:27
【问题描述】:
public class TestConnection extends Activity {
/** Called when the activity is first created. */
public static final UUID BluetoothSerialUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private BluetoothAdapter _adapter;
BluetoothSocket socket=null;

@Override 
protected void onPause() {
    try {
        socket.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView text = (TextView) findViewById(R.id.mainText);
    text.setText("This is a test");

    String deviceAddress = "05:03:e8:c0:bf:c0";
    _adapter = BluetoothAdapter.getDefaultAdapter();

    BluetoothDevice device = _adapter.getRemoteDevice(deviceAddress);

    try {
        socket = device.createRfcommSocketToServiceRecord(BluetoothSerialUuid);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        socket.connect();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}

我正在尝试使用该站点的一些代码:

http://zornsoftware.talsit.info/blog/pairing-spp-bluetooth-devices-with-android-phones.html

克服 android 跳过 0x00 类蓝牙设备的事实。但是,当我这样做时: _adapter.getRemoteDevice(deviceAddress);

我从来没有得到回应

【问题讨论】:

    标签: java android bluetooth


    【解决方案1】:

    我意识到失败的原因是现在在清单文件中拥有正确的权限。

    【讨论】:

      猜你喜欢
      • 2017-12-14
      • 1970-01-01
      • 2011-12-23
      • 2017-08-25
      • 2011-10-15
      • 2011-05-01
      • 2011-10-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多