将数据写入蓝牙

时间:2018-01-02 19:59:54

标签: java android bluetooth

在我的项目中,我在其他文件中有两个类。

第二类是关于发送数据的文档AndroidStudio中的类。 https://developer.android.com/guide/topics/connectivity/bluetooth.html

第一堂课是我的主要活动。

所以,我有这个代码片段:

     public class MyBluetoothService {
//some code
public class ConnectedThread extends Thread {
//some code
 public void write(byte[] bytes) {//some code
}
}
}

在第一堂课中,我尝试使用方法:write()就像上帝所说:

    MyBluetoothService.ConnectedThread send= new MyBluetoothService.ConnectedThread();
send.write(my_data);

但我有这个错误:

Error:(74, 55) error: an enclosing instance that contains MyBluetoothService.ConnectedThread is required

为什么呢?问题出在哪儿?我该怎么做才能解决这个问题?

0 个答案:

没有答案
相关问题