我想用藍牙聊天的例子爲api-10,在我的micromax pfhone。Bleutooth聊天Api 10不工作
當我掃描設備時,它顯示了安全列表和非安全列表。 但是,當我嘗試連接它顯示無法連接。
而且是的UUID:
private static final UUID MY_UUID_SECURE = UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
private static final UUID MY_UUID_INSECURE =UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");
我想這個帖子, Service discovery failed exception using Bluetooth on Android,但沒有任何變化。
任何想法?
這是我的代碼,用於在配對時連接到藍牙設備。我從Android的API-10樣品驗證碼:
try {
if (secure) {
tmp = device.createRfcommSocketToServiceRecord(
MY_UUID_SECURE);
} else {
tmp = device.createInsecureRfcommSocketToServiceRecord(
MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
}
mmSocket = tmp;
}
public void run() {
Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
setName("ConnectThread" + mSocketType);
// Always cancel discovery because it will slow down a connection
mAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) {
Log.e(TAG, "unable to close() " + mSocketType +
" socket during connection failure", e2);
}
connectionFailed();
return;
}
顯示您的代碼。 –
Hai我發佈了我的代碼........ – Haris
Hi @Haris 你有什麼解決方案嗎?我也被困在同一地區。它的工作與三星galaxy Y,但不是micromax A52 –