我的课程在 MainActivity :
中声明public class MainActivity extends ListActivity {
public class CommunicatorServiceImpl implements CommunicatorService{
@Override
public Communicator createCommunicatorThread(BluetoothSocket socket) {
return new CommunicatorImpl(socket, new CommunicatorImpl.CommunicationListener() {
@Override
public void onMessage(final String message) {
runOnUiThread(new Runnable() {
@Override
public void run() {
textData.setText(textData.getText().toString() + "\n" + message);
}
});
}
});
}
}
private final CommunicatorService communicatorService = new CommunicatorServiceImpl();
}
我需要将 communicatorService 转移到该服务。此对象与服务一起使用该线程。据我所知,我无法将对象作为服务构造函数的参数进行传输。我怎么能这样做?
提前致谢。