Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Device Pairing fail to Discovery callback #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/java/me/aflak/libraries/ScanActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public void onDeviceUnpaired(BluetoothDevice device) {
public void onError(int errorCode) {

}

@Override
public void onPairingFailed(BluetoothDevice device) {

}
};

private void startChatActivity(BluetoothDevice device){
Expand Down
10 changes: 10 additions & 0 deletions bluetooth/src/main/java/me/aflak/bluetooth/Bluetooth.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,16 @@ public void run() {
}
});
}
} else if (state == BluetoothDevice.BOND_NONE && prevState == BluetoothDevice.BOND_BONDING) {
context.unregisterReceiver(pairReceiver);
if (discoveryCallback != null) {
ThreadHelper.run(runOnUi, activity, new Runnable() {
@Override
public void run() {
discoveryCallback.onPairingFailed(device);
}
});
}
}
}
else if(BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public interface DiscoveryCallback{
void onDevicePaired(BluetoothDevice device);
void onDeviceUnpaired(BluetoothDevice device);
void onError(int errorCode);
void onPairingFailed(BluetoothDevice device);
}