我的简单SPP服务器似乎只是从我的MainActivity中从我的ArrayList中获取一个项目,它怎么会赢得不打印?当我删除" \ n"时也很奇怪从我的for循环到设置最终消息我得到" 86"但是当没有" \ n"没有打印???
android ConnectTest类
ArrayList<Integer> temp;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.connect_test);
temp = getIntent().getIntegerArrayListExtra("lightInformation");
out = (TextView) findViewById(R.id.out);
out.append("\n...In onCreate()...");
btAdapter = BluetoothAdapter.getDefaultAdapter();
CheckBTState();
}
@Override
public void onStart() {
super.onStart();
out.append("\n...In onStart()...");
}
@Override
public void onResume() {
super.onResume();
out.append("\n...In onResume...\n...Attempting client connect...");
// Set up a pointer to the remote node using it's address.
BluetoothDevice device = btAdapter.getRemoteDevice(address);
// Two things are needed to make a connection:
// A MAC address, which we got above.
// A Service ID or UUID. In this case we are using the
// UUID for SPP.
try {
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
AlertBox("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");
}
// Discovery is resource intensive. Make sure it isn't going on
// when you attempt to connect and pass your message.
btAdapter.cancelDiscovery();
// Establish the connection. This will block until it connects.
try {
btSocket.connect();
out.append("\n...Connection established and data link opened...");
} catch (IOException e) {
try {
btSocket.close();
} catch (IOException e2) {
AlertBox("Fatal Error", "In onResume() and unable to close socket during connection failure" + e2.getMessage() + ".");
}
}
// Create a data stream so we can talk to server.
out.append("\n...Sending message to server...");
try {
outStream = btSocket.getOutputStream();
} catch (IOException e) {
AlertBox("Fatal Error", "In onResume() and output stream creation failed:" + e.getMessage() + ".");
}
String finalMessage = "";
for (int i = 0; i < temp.size(); i++) {
finalMessage = finalMessage + String.valueOf(temp.get(i)) + "\n";
}
String message = finalMessage;
byte[] msgBuffer = message.getBytes();
try {
outStream.write(msgBuffer);
} catch (IOException e) {
String msg = "In onResume() and an exception occurred during write: " + e.getMessage();
在eclipse服务器上读取
Server Started. Waiting for clients to connect...
Remote device address: E458E7526EE3
Remote device name: SAMSUNG-SM-G920V
83
BlueCove stack shutdown completed
答案 0 :(得分:0)
用它修复它,不确定为什么它有效但是它确实: 注释掉了这个:
void(^)(bool granted, CFErrorRef error)
并简单地替换为:
select {
-webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: '';
}