我的问题是GoogleApiClient没有正确添加游戏范围。 它运行良好,直到PlayServices 8.1
以下是初始化ApiClient
的代码void beginListenForData() {
final Handler handler = new Handler();
final byte delimiter = 10;
stopWorker = false;
readBufferPosition = 0;
readBuffer = new byte[1024];
workerThread = new Thread(new Runnable() {
public void run() {
while (!Thread.currentThread().isInterrupted() && !stopWorker) {
try {
int bytesAvailable = mmInputStream.available();
if (bytesAvailable > 0) {
byte[] packetBytes = new byte[bytesAvailable];
mmInputStream.read(packetBytes);
for (int i = 0; i < bytesAvailable; i++) {
byte b = packetBytes[i];
if (b == delimiter) {
byte[] encodedBytes = new byte[readBufferPosition];
System.arraycopy(readBuffer, 0,
encodedBytes, 0,
encodedBytes.length);
final String data = new String(
encodedBytes,"US-ASCII" );
readBufferPosition = 0;
handler.post(new Runnable() {
public void run() {
sampleView.setText(data);
str = sampleView.getText()
.toString();
Log.i("Data", data);
}
});
} else {
readBuffer[readBufferPosition++] = b;
}
}
}
} catch (IOException ex) {
stopWorker = true;
}
}
}
});
workerThread.start();
try {
String command1=command.getText().toString();
mmOutputStream.write(command1.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
这里的截图显示,尽管范围是游戏范围,但没有被要求任何权限。
有什么想法吗?