Comments (1)
I encountered with this problem.
The first time connect failed, the second time succeeded.
This situation will happened when device is already connected, but your application is dead or not started. When application starting, it will start a connection, but actually the connection is already built up.
I fix it by connecting it again.
Just modify BluetoothService->ConnectThread.run().
public void run() {
// 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) {
}
//try again
try {
mmSocket.connect();
} catch (IOException e1) {
e1.printStackTrace();
connectionFailed();
}
}
// Reset the ConnectThread because we're done
synchronized (BluetoothService.this) {
mConnectThread = null;
}
// Start the connected thread
connected(mmSocket, mmDevice, mSocketType);
}
Wish it helps.
from bluetoothspplibrary.
Related Issues (20)
- 이 블루투스 라이브러리를 사용하려는 한국인들을 위해 HOT 1
- transfer intent
- take multiple masseges on recived data
- Bt
- Context HOT 1
- NullPointerException at app.akexorcist.bluetotohspp.library.BluetoothService$AcceptThread.run (BluetoothService.java:2)
- Not scanning or discoverying nearby bluetooth devices. (startActivityForResult) HOT 2
- Prematurely terminating data packets with byte values of 10 (LF) and 13 (CR) HOT 2
- Can't read data from a BT barcode reader
- Activity crashed A/libc: Fatal signal 11 (SIGSEGV), code 1 HOT 1
- thank u
- getBluetoothService() called with no BluetoothManagerCallback HOT 1
- targetSdkVersion < 4
- the package name is spelled incorrectly...
- ConnectThread NullPointerException when the BT has been manually disabled
- How to make own Reciver
- bt.setupService()
- Fixing send function HOT 1
- How do you solve the issue of broken packets/messages? HOT 1
- Question: Will this library give me serial port in PC when my android device connected to PC using BT?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bluetoothspplibrary.